I am trying to set up a really simple coming-soon page with a contact form. I have uploaded everything here (click contact us now button).
Now, when I fill in the information and click send, it will give me an error message. I can't see anything wrong and have error reporting set to on (maybe on the wrong place), here's the php code:
<?php
ini_set('display_startup_errors',1);
ini_set('display_errors',1);
error_reporting(-1);
if (isset($_REQUEST['name'],$_REQUEST['email'])) {
$name = $_REQUEST['name'];
$email = $_REQUEST['email'];
$message = $_REQUEST['message'];
$to = 'editedforstackoverflow';
$subject = 'Contact Request From Website';
$headers = "From: ".$name." <".$email."> \r\n";
$send_email = mail($to,$subject,$message,$headers);
echo ($send_email) ? 'success' : 'error';
}
?>
And here the js part:
$('#ajax-contact').on('submit', function() {
// Add text 'loading...' right after clicking on the submit button.
$('.output_message').text('Loading...');
var form = $(this);
$.ajax({
url: form.attr('action'),
method: form.attr('method'),
data: form.serialize(),
success: function(result) {
if (result == 'success') {
$('.output_message').text('Nachricht erfolgreich geschickt!');
} else {
$('.output_message').text('Da ist leider ein Fehler unterlaufen!');
}
}
});
// Prevents default submission of the form after clicking on the submit button.
return false;
});
I can't really see what error I made, any help would be appreciated!