Aucun post recu par formulaire ajax
Bonjour,
mon formulaire m'envoi un email mais aucune information des post renseigner.
Voici le code :
Code:
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
| <?php
$sendto = "gaborit.elodie@gmail.com";
$usermail = $_POST['email'];
$nom = $_POST['nom'];
$prenom = $_POST['prenom'];
$tel = $_POST['tel'];
$date_arrive = $_POST['date_arrive'];
$date_depart = $_POST['date_depart'];
$nbre_adultes = $_POST['nbre_adultes'];
$nbre_enfants = $_POST['nbre_enfants'];
$content = nl2br($_POST['msg']);
$subject = "Formulaire de contact";
$headers = "From: " . strip_tags($usermail) . "\r\n";
$headers .= "Reply-To: ". strip_tags($usermail) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html;charset=utf-8 \r\n";
$msg = "<html><body style='font-family:Arial,sans-serif;'>";
$msg .= "<h2 style='font-weight:bold;border-bottom:1px dotted #ccc;'>Contact formulaire</h2>\r\n";
$msg .= "<p><strong>Envoyer par :</strong> ".$usermail."</p>\r\n";
$msg .= "<p><strong>Nom :</strong> ".$nom."</p>\r\n";
$msg .= "<p><strong>Tel :</strong> ".$tel."</p>\r\n";
$msg .= "<p><strong>Date d'arrivée :</strong> ".$date_arrive."</p>\r\n";
$msg .= "<p><strong>Date de départ :</strong> ".$date_depart."</p>\r\n";
$msg .= "<p><strong>Nombre adultes :</strong> ".$nbre_adultes."</p>\r\n";
$msg .= "<p><strong>Nombre enfants :</strong> ".$nbre_enfants."</p>\r\n";
$msg .= "<p><strong>Message:</strong> ".$content."</p>\r\n";
$msg .= "</body></html>";
if(@mail($sendto, $subject, $msg, $headers)) {
echo "true";
} else {
echo "false";
}
?> |
et page formulaire :
Code:
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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
| <div id="inline">
<h2>Formulaire de contact</h2>
<form id="contact" name="contact" action="#" method="post">
<table>
<tr>
<td>
<label for="email">Nom</label>
</td><td>
<input id="nom" name="nom" class="txt">
</td>
</tr>
<tr>
<td>
<label for="email">Telephone</label>
</td>
<td>
<input id="tel" name="tel" class="txt">
</td>
</tr>
<tr>
<td>
<label for="email">Date d'arrivée</label>
</td>
<td>
<input id="date_arrive" name="date_arrive" class="txt">
</td>
</tr>
<tr>
<td>
<label for="email">Date de départ</label>
</td>
<td>
<input id="date_depart" name="date_depart" class="txt">
</td>
</tr>
<tr>
<td>
<label for="email">Nombre d'adultes</label>
</td>
<td>
<input id="nbre_adultes" name="nbre_adultes" class="txt">
</td>
</tr>
<tr>
<td>
<label for="email">Nombre enfants</label>
</td>
<td>
<input id="nbre_enfants" name="nbre_enfants" class="txt">
</td></tr>
<tr><td>
<label for="email">E-mail</label>
</td>
<td>
<input id="email" name="email" class="txt">
</td></tr>
<tr><td>
<tr><td>
<label for="msg">Message</label><br />
</td>
<td>
<textarea id="msg" name="msg" class="txtarea"></textarea>
</td></tr>
<tr><td>
<button id="send">Envoyer</button>
</td></tr>
</table>
</form>
</div>
<script type="text/javascript">
function validateEmail(email) {
var reg = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return reg.test(email);
}
$(document).ready(function() {
$(".modalbox").fancybox();
$("#contact").submit(function() { return false; });
$("#send").on("click", function(){
var emailval = $("#email").val();
var msgval = $("#msg").val();
var msglen = msgval.length;
var mailvalid = validateEmail(emailval);
if(mailvalid == false) {
$("#email").addClass("error");
}
else if(mailvalid == true){
$("#email").removeClass("error");
}
if(msglen < 4) {
$("#msg").addClass("error");
}
else if(msglen >= 4){
$("#msg").removeClass("error");
}
if(mailvalid == true && msglen >= 4) {
// if both validate we attempt to send the e-mail
// first we hide the submit btn so the user doesnt click twice
$("#send").replaceWith("<em>sending...</em>");
$.ajax({
type: 'POST',
url: 'sendmessage.php',
data: $("#contact").serialize(),
success: function(data) {
if(data == "true") {
$("#contact").fadeOut("fast", function(){
$(this).before("<p class='success'><strong>Votre message à été envoyé!Merci.</strong></p>");
setTimeout("$.fancybox.close()", 1000);
});
}
}
});
}
});
});
</script> |
merci.