There is an ajax request:
$(function() { $('#backmail').submit(function(e) { var $form = $(this); var button = $('#backmail button[type="submit"]') $.ajax({ type: 'POST', url: 'backmail.php', data: $form.serialize(), }).done(function() { $form.slideUp('slow', function(){ $(this).remove(); }); $('#success-highlight').show(); }).fail(function() { $form.slideUp('slow', function(){ $(this).remove(); }); $('#error-highlight').show(); }); e.preventDefault(); }); }); And there is a PHP script that receives and sends this data to me by mail:
<? // config $adminemail="andrewdymov@gmail.com"; $date=date("dmy"); $time=date("H:i"); // confirm data $name = $_POST['name']; $email = $_POST['mail']; $subject = $_POST['subject']; $message = $_POST['message']; if (!preg_match("/.+@.+\..+/i", strtolower($email))) { header("HTTP/1.1 500 Internal Server Error"); } else { $msg="<p>Отправлено: $time $date</p> <p>Имя: $name</p> <p>E-mail: $email</p> <p>Тема: $subject</p> <p>Сообщение: $message</p>"; mail("$adminemail", "$subject", "$message"); } ?> The essence of the problem lies in the fact that no matter what abru-cadabra I wrote in the email field, the data to the php file is still sent successfully and the php script returns code 200, although I should have returned 500 to me. I did something not this way?