<?php
/**
* Example usage of SkunkyForm Package with Mysql Connection passing an array to the constructor
*
* @package SkunkyForm
*/
require_once('../Form.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >
<head>
<title>Premier TP</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!--##### CSS #####-->
<link rel="stylesheet" media="screen" type="text/css" href="../css/structure.css" />
<link rel="stylesheet" media="screen" type="text/css" href="../css/form.css" />
<link rel="stylesheet" media="screen" type="text/css" href="../css/result.css" />
</head>
<body id="public">
<?php
$monTab = array(
"last_name" => array(
"label" => "Nom",
"required" => true,
"rule" => "validateName",
"type" => "input",
"errormsg" => "Votre nom n'est pas valide !",
"options" => array()
),
"first_name" => array(
"label" => "Prénom",
"required" => true,
"rule" => "validateName",
"type" => "input",
"errormsg" => "Votre prénom n'est pas valide !",
"options" => array()
),
"mail" => array(
"label" => "Email",
"required" => true,
"rule" => "validateMail",
"type" => "input",
"errormsg" => "Votre adresse email n'est pas valide !",
"options" => array()
),
"message" => array(
"label" => "Message",
"required" => false,
"rule" => "",
"type" => "textarea",
"errormsg" => "Votre message n'est pas valide !",
"options" => array()
)
);
$monForm = new Form($monTab);
$monForm->setActiveJs(true);
if(!empty($_POST)) {
$monForm->setFrom($_POST);
if ($monForm->validate()) {
$monForm->saveForm("mysql", array("hostname" => "localhost", "login" => "root", "password" => "root", "dbname" => "tp_dam"), "post_list");
$monForm->displayResult();
/*
try {
$monForm->sendByMail("hide@address.com");
} catch(Exception $e){
echo $e->getMessage();
}
*/
} else {
$monForm->displayForm();
}
} else {
$monForm->displayForm();
}
?>
</body>
</html>