Good day. The topic is already beaten, but I'm still stupid.
The title seems to be all clear.
There is such Html:
<form action="" method="POST" id="askform"> <table> <tr> <td>Имя</td><td><input type="text" name="name" placeholder="Иванов Иван Иванович" required pattern="^[А-Яа-яЁё ]+$"></td> </tr> <tr> <td>E-mail</td><td><input name="email" placeholder="example@gmail.com" required type="email"></td> </tr> <tr> <td>Вопрос</td><td><textarea type="text" name="question" placeholder="Опишите, что Вас интересует" required></textarea></td> </tr> </table> <input id="doask" type="submit" value="Отправить"/> </form> <script> $(document).ready(function(){ $("#askform").submit(function() { var form_data = $(this).serialize(); $.ajax({ type: "POST", url: "php/ask.php", data: form_data, success: function() { alert('Успешно'); }, error: function() { alert('возникла ошибка'); }; return false; }); }); }); </script> And, accordingly, PHP:
<?php if((isset($_POST['name'])&&$_POST['name']!="")&&(isset($_POST['email'])&&$_POST['email']!="") &&(isset($_POST['question'])&&$_POST['question']!="")){ $to = 'testmail@gmail.com'; $subject = 'Вопрос'; $name = $_POST['name']; $email = $_POST['email']; $question = $_POST['question']; $message=' <html> <head> <title>'.$subject.'</title> </head> <body> <p>Имя: '.$name.'</p> <p>email: '.$email.'</p> <p>Вопрос: '.$question.'</p> </body> </html>'; $headers = "Content-type: text/html; charset=utf-8 \r\n"; $headers .= "From: testmail@gmail.com\r\n"; mail($to, $subject, $message, $headers); ?> The sadness is that there is no message, and the page reloads. Where is my mistake?
Thank you in advance