Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <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>
- <?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 rn";
- $headers .= "From: testmail@gmail.comrn";
- mail($to, $subject, $message, $headers);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement