Answer the question
In order to leave comments, you need to log in
Submitting a form?
Hello.
There are such cards.
Clicking the button opens a modal window with a form. There is only one form.
It is necessary that when submitting the form, the desired header comes to the mail.
How can I do that?
js handler:
$('form').each(function() {
$(this).submit(function () {
var formID = $(this).attr('id'); // Получение ID формы
var formNm = $('#' + formID);
$.ajax({
type: 'POST',
url: 'form.php', // Обработчик формы отправки
data: formNm.serialize(),
success: function (data) {
// Вывод текста результата отправки в текущей форме
$('#modal-thank').arcticmodal();
}
});
return false;
});
});
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (isset($_POST['name'])) {$name = $_POST['name'];}
if (isset($_POST['phone'])) {$phone = $_POST['number'];}
$to = "[email protected]"; /*Укажите ваш адрес электронной почты*/
$headers = "Content-type: text/plain; charset = utf-8";
$subject = "$formData";
$message = "Имя: $name \n\nТелефон: $phone \n\n";
$send = mail ($to, $subject, $message, $headers);
if ($send == 'true')
{
echo "<center>Спасибо за отправку вашего сообщения!</center>";
}
else
{
echo "<center><b>Ошибка. Сообщение не отправлено!</b></center>";
}
} else {
http_response_code(403);
echo "Попробуйте еще раз";
}
?>
Answer the question
In order to leave comments, you need to log in
Add a hidden input to your forms:
<input type="hidden" name="title" value="Заголовок соответствующего блока">
if (isset($_POST['title'])) {$title = $_POST['title'];}
...
$message = "Заголовок: $title \n\nИмя: $name \n\nТелефон: $phone \n\n";
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question