1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| if ($_POST) // plus précisément fodrai mettre un champ caché ds le html avec une value kelconque, verifier $_POST[hidden_name] == hidden_value mé bon ca marche kan mem la
{
$form_error = "";
while(list($id,$value) = each($_POST)) //Test sur remplissage des champs vide obligatoire et contenant des caracteres interdit
{
if (!empty($value) && !preg_match('/^[a-z0-9]+$/i', $value) )
//if(empty($value) && $id != "photo" && $id != "street2" && $id != "url" && $id != "description" && $id != "mail")
$form_error .= "Le champ ".$id." est vide ou incorrect<br />";
//if (!preg_match('/^[a-z0-9]+$/i', $value) )
// $form_error .= "Le champ ".$id." est incorrect <br />";
}
if ($_POST[pass] == $_POST[repass]) // Test sur password
$form_error .= "password verification : OK";
else
$form_error .= "password error";
if ($_POST['mail']) //Test sur l'adresse mail
{
$_POST['mail'] = htmlspecialchars($_POST['mail']); // faut utiliser htmlspecialchars sur chaq champs $_POST n'est il pas ?
if (preg_match("#^[a-z0-9._-]+@[a-z0-9._-]{2,}\.[a-z]{2,4}$#", $_POST['mail']))
$form_error .= "mail ok";
else
$form_error .= "Invalid mail format";
}
if ($form_error == "") // aucune erreur détectée
header('?page=confirm.php'); // redirection
} |
Partager