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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
| <?php
$regex = "/^[-+.\w]{1,64}@[-.\w]{1,64}\.[-.\w]{2,6}$/i";
$courriel = $_POST['mail'];
if(!empty($_POST)){
//
// Debug
//
//
// Récupération normale des informations
//
$missing_fields = array();
if (preg_match($regex, $courriel)) {
$missing_fields[] = '"courriel",';
echo "L'adresse $courriel est valide";
} else {
echo "L'adresse $courriel n'est pas valide";
}
if(empty($_POST['nom'])){
$missing_fields[] = '"Nom",';
}
if(empty($_POST['prenom'])){
$missing_fields[] = '"Prenom",';
}
if(empty($_POST['Telephone'])){
$missing_fields[] = '"Telephone",';
}
if(empty($_POST['date'])){
$missing_fields[] = '"Date",';
}
}
echo '<br /><br />';
if(count($missing_fields) > 0){
echo '<strong>Il faut remplir les champs suivants</strong>'.implode( ', ' , $missing_fields);
}
else{
// traitement
if( isset($_POST['nom']) ) // si formulaire soumis{
$to = 'rabi29@orange.fr';
$sujet = 'demande de Pre-reservation';
$from = $_POST['mail'];
$nom = "Nom :".$_POST['nom']."\n\r";
$Prenom = "Prenom : ".$_POST['prenom']."\n\r";
$Telephone = "Telephone :".$_POST['Telephone']."\n\r";
$message = "\nMessage:\n\t$Prenom\n\t$nom\n\t$Telephone";
if (mail($to , $sujet , $message , "From: $from"))
{
echo'
<script type="text/javascript">
<!--
alert("Votre message a été envoyé .");
//-->
</script>';
}
else
{
echo'
<script type="text/javascript">
<!--
alert("Votre message n\'a pas pu être envoyé !!!");
//-->
</script>'
;
}
}
}
echo '<br /><br />';
?> |
Partager