Page 1 sur 1

Formulaire avec validation email qui ne marche pas

Posté : 16 mars 2013, 08:41
par forumeur
Bonjour,

Je demande votre aide car je m'arrache les cheveux sur mon formulaire de commentaires.

A la soumission, il m'indique "email incorrect". Il ne marche qu'avec l"email pré-rempli en exemple.

Code : Tout sélectionner

if(!empty($_POST["email_expediteur"])) { if(!preg_match('#^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,6}$#',$_POST["email_expediteur"]) || preg_match_all("#hotmail|live|msn#",$_POST["email_expediteur"],$out)) { echo' <script type="text/javascript"> alert("Email incorrect"); setTimeout("window.location=\'\'",5000); </script>'; }else{ # was there a reCAPTCHA response? if ($_POST["recaptcha_response_field"]) { $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if ($resp->is_valid) { echo' <script type="text/javascript"> alert("Votre commentaire a été envoyé."); </script>';
Le formulaire :

Code : Tout sélectionner

echo '<br/><div style="margin:20px;"> <form style="width:600px;margin:auto;"action="';echo $_SERVER["PHP_SELF"];echo'" method="post" name="add" OnSubmit="return champsok()"> <table style="width:100%;" cellpadding="0" cellspacing="0" border="0"> <tr> <body>'; ?> <!-- the body tag is required or the CAPTCHA may not show on some browsers --> <!-- your HTML content --> <td class="text2"><span class="style1">Votre email (Obligatoire, ne sera pas publié) :</span></td><td><br /> <input type="text" maxlength="80" size="40" name="email_expediteur" id="email_expediteur" value="[email protected]" onfocus="if (this.value=='[email protected]') this.value=''" /></td>...
Comme je l'ai indiqué, la soumission fonctionne avec l'email d'exemple ([email protected]).