Je refais un post un peu plus clair que le dernier en espérant qu'il aura un meilleur succès.
Ci-dessous un formulaire avec un contrôle du champ via la fonction décrite, voici l'objectif :
- si champ vide, réafficher la même page avec le message d'erreur
- si champs renseigné, afficher la page test2.php
En fait cela fonctionne seulement quand je valide une seconde fois.
Quelqu'un peut-il m'aider ? A l'aide je n'en peux plus ...
MERCI !
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Document sans nom</title>
</head>
<body>
<table width="800" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<?php
function checkmail($email)
{
$valid_mail = False;
if($email == ''){
return array('valid' => false,'message' => 'Veuillez saisir une adresse e-mail');
}else{
return array('valid' => true,'message' => '');
}
}
if ((isset($_POST["mail_nv_client"]))){
$mail_nv_client = $_POST["mail_nv_client"];
echo $mail_nv_client;
$checkmail = checkmail($mail_nv_client);
echo $checkmail['message'];
}
echo '<br>';
?>
<form <?php if ((isset($checkmail['valid'])) AND ($checkmail['valid'] == TRUE)) {?> action="test2.php" <?php } else {?> action="test.php" <?php }?> method="POST" name="">
<?php
echo 'E-mail * : <input type="text" name="mail_nv_client" value=""><br>';
echo '<input type="submit" name="valider" value="OK"><br>';
echo '</form>';
?>
</td>
</tr>
</table>
</body>
</html>