php - AJAX Contact form - not working properly -
i've created simple ajax, jquery, php contact form on website inputs: name, email , message. problem when write actual email email field message never comes inbox. works when email input field contains 1 word no @ sign.
my html:
<p class="form">name</p> <input type="text" name="username" id="username"> <p class="form">email</p> <input id="useremail" type="email" name="useremail"> <p class="form">message</p> <textarea id="msg" name="msg"></textarea><button onclick="sendcontact();"></button>
my javascript:
function sendcontact() { jquery.ajax({ url: "contact_me.php", data:'username='+$("#username").val()+'&useremail='+ $("#useremail").val()+'&msg='+ $("#msg").val(), type: "post", success:function(){ sendsuccess(); }, error:function (){} }); };
my php:
<?php $to = "dusset@gmail.com"; $from = $_post['useremail']; $name = $_post['username']; $subject = $name . "has sent message .design"; $message = $name . " wrote following:" . "\n\n" . $_post['msg']; $headers = "from:" . $from; mail($to,$subject,$message,$headers);?>
any idea problem, please?
try changing how pass data ajax. example:
function sendcontact() { jquery.ajax({ url: "contact_me.php", data: { username: $("#username").val(), useremail: $("#useremail").val(), msg: $("#msg").val()}, type: "post", success:function(){ sendsuccess(); }, error:function (){} }); };
Comments
Post a Comment