Hey,
I cannot seem to get the mail(); function working with my contact form. I have tested the form in many ways and the only thing it is not doing is mailing the data.
Here is the code:
contact.php:
Here is the page it's for http://stephaniesofokleous.co.uk/contact.html so you can see the console returning the data when you click the "send" button. It's just the mail part which isn't working.
I cannot seem to get the mail(); function working with my contact form. I have tested the form in many ways and the only thing it is not doing is mailing the data.
Here is the code:
HTML:
<input type="submit" value="SEND" id="send" />
<script>
$('#send').click(function(e) {
e.preventDefault();
var datastring = "to=contact@mydomain.com&subject=Contact&body=TEST";
alert(datastring);
$.ajax({
type: "POST",
url: "contact.php",
data: datastring,
success: function(data){
console.log(data);
alert("success!");
}
});
});
</script>
contact.php:
PHP:
<?php
$to = $_REQUEST['to'];
$subject = $_REQUEST['subject'];
$body = $_REQUEST['body'];
mail($to, $subject, $body);
$data = $to . ", " . $subject . ", " . $body;
echo $data;
?>
Here is the page it's for http://stephaniesofokleous.co.uk/contact.html so you can see the console returning the data when you click the "send" button. It's just the mail part which isn't working.