Hello,
i have been at this all day!
I am trying to customize a contact form which had originally 4 fields. I have added more fields, but the email sent only includes a maximum of 4, regardless whether they are the new ones or the originals, or a mix of both, only 4 fields are sent. Here is my java script and php code if anyone can help me out.
thanks alot!
java script:
$(document).ready(function(){
$("#error").hide();
$("#success").hide();
$("#contactForm #submit").click(function() {
$("#error").hide();
var prenom = $("input#prenom").val();
if(prenom == ""){
$("#error").fadeIn().text("Prénom requis.");
$("input#prenom").focus();
return false;
}
var nom = $("input#nom").val();
if(nom == ""){
$("#error").fadeIn().text("Nom requis.");
$("input#nom").focus();
return false;
}
var jour = $("input#jour").val();
if(jour == ""){
$("#error").fadeIn().text("Date de naissance requise.");
$("input#jour").focus();
return false;
}
var mois = $("input#mois").val();
if(mois == ""){
$("#error").fadeIn().text("Date de naissance requise.");
$("input#mois").focus();
return false;
}
var annee = $("input#annee").val();
if(annee == ""){
$("#error").fadeIn().text("Date de naissance requise.");
$("input#annee").focus();
return false;
}
var email = $("input#email").val();
if(email == ""){
$("#error").fadeIn().text("Courriel requis");
$("input#email").focus();
return false;
}
var sendMailUrl = $("#sendMailUrl").val();
var to = $("#to").val();
var from = $("#from").val();
var subject = $("#subject").val();
// data string
var dataString = 'prenom='+ prenom
+ '&nom=' + nom
+ '&jour=' + jour
+ '&mois=' + mois
+ '&annee=' + annee
+ '&email=' + email
+ '&to=' + to
+ '&from=' + from
+ '&subject=' + subject;
// ajax
$.ajax({
type:"POST",
url: sendMailUrl,
data: dataString,
success: success()
});
});
function success(){
$("#success").fadeIn();
//$("#contactForm").fadeOut();
}
return false;
});
php:
<?php
//vars
$subject = $_POST['subject'];
$to = explode(',', $_POST['to'] );
$from = $_POST['email'];
//data
$msg = "PRÉNOM: " .$_POST['prenom'] ."<br>\n";
$msg = "NOM: " .$_POST['nom'] ."<br>\n";
$msg .= "JOUR: " .$_POST['jour'] ."<br>\n";
$msg .= "MOIS: " .$_POST['mois'] ."<br>\n";
$msg .= "ANNEE: " .$_POST['annee'] ."<br>\n";
$msg .= "COURRIEL: " .$_POST['email'] ."<br>\n";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=UTF-8\r\n";
$headers .= "From: <".$from. ">" ;
foreach($to as $mail){
mail($mail, $subject, $msg, $headers);
}
?>
<?php echo "Xy6Hy";?>:


