post variables and email not being sent
I can't seem to figure out why this code isn't working, I am trying to send variables from a contact form to a php file by using the $.post method.
Here is the code, I apologize, it may be sloppy, first time using jquery.
-
//define variables
var arr = new Array($("[name=name]").val(),$("[name=email]").val(),$("[name=message]").val(),$("[name=human]").val());
var humanresponse = $("[name=nothuman']").val();
//send variables
$.post("../send_email.php", { name: arr[0], email: arr[1], message: arr[2], nothuman: humanresponse } );
In the php file:
-
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$message = $message."\r\n".$_POST['nothuman'];
mail("anemail@somewhere.com","This is a subject",$message,"From: $name $email \r\n");
I've followed a tutorial,
http://trevordavis.net/blog/tutorial/ajax-forms-with-jquery/,and everything seems to be the same (except for the validation, I did mine a different way).
If anyone can help that would be awesome. I appreciate any and all help.
Thanks in advance,
Justin