Answer the question
In order to leave comments, you need to log in
How to return to the main page from a modal window with a form?
Good evening everyone. Guys tell me please.
Made a feedback form in a modal window. How to make it so that after sending the data, it returns to the main page, but it is better that it be without reloading the page and an inscription about successful sending pops up? I give the code below:
HTML
<form action="form.php" method= "POST">
<p align="center" style="font-family:NautilusPompiliusRegular;">
Друзья, <br />
Вам осталось заполнить данные, и мы Вам перезвоним.<br />
</p>
<p>
<label> <span style="font-family:NautilusPompiliusRegular;">Имя</span>
<input type="text" name="name" class="name-q">
</label>
</p>
<p>
<label> <span style="font-family:NautilusPompiliusRegular;">Телефон</span>
<input type="text" name="phone" class="name-q">
</label>
</p>
<center><input type="submit" name="submit" value="Купить" class="offer-item__btn malina-font"></center>
</form>
<?php
// если была нажата кнопка "Отправить"
if($_POST['submit']) {
$name = substr(htmlspecialchars(trim($_POST['name'])), 0, 1000);
$phone = substr(htmlspecialchars(trim($_POST['phone'])), 0, 1000000);
// $to - кому отправляем
$to = '[email protected]';
// $from - от кого
$from='[email protected]';
$subject = 'Новый запрос с сайта ';
// функция, которая отправляет наше письмо
mail($to, $subject, $name, $phone, 'From:'.$from);
echo 'Спасибо! Ваше письмо отправлено.';
}
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question