Last active
April 26, 2018 08:36
-
-
Save madeas/1ba4b155f10b01c4d0bac10c762988db to your computer and use it in GitHub Desktop.
Feedback form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form id="form5" method="POST" action="feedback.php"> | |
<div class="form-row"> | |
<div class="col"> | |
<input type="text" class="name form-control" name="name" required="required" placeholder="Представьтесь, пожалуйста" x-autocompletetype="name"> | |
</div> | |
</div> | |
<div class="form-group"> | |
<label for="recipient-mail" class="col-form-label">Ваш email:</label> | |
<input type="text" name="email" class="email form-control" id="recipient-mail" required="required" placeholder="[email protected]" x-autocompletetype="email"> | |
</div> | |
<div class="form-group"> | |
<label for="recipient-name" class="col-form-label">Ваш телефон:</label> | |
<input type="text" class="phone form-control" name="phone" id="recipient-name" placeholder="+7" x-autocompletetype="phone"> | |
</div> | |
<div class="form-group"> | |
<label for="message-text" class="col-form-label">Сообщение:</label> | |
<textarea name="message" id="message-text" class="message form-control"></textarea> | |
</div> | |
<div class="d-flex justify-content-between"> | |
<button type="submit" name="submit" class="btn btn-primary">Заказать</button> | |
<input type="hidden" name="formData" value="Технический регламент ТР ТС 020/2011 «Электромагнитная совместимость технических средств»"> | |
<button type="button" class="btn btn-secondary" data-dismiss="modal">Закрыть</button> | |
</div> | |
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
$(document).ready(function () { | |
$('form').submit(function () { | |
var formID = $(this).attr('id'); // Получение ID формы | |
var formNm = $('#' + formID); | |
$.ajax({ | |
type: 'POST', | |
url: 'feedback.php', // Обработчик формы отправки | |
data: formNm.serialize(), | |
success: function (data) { | |
// Вывод текста результата отправки в текущей форме | |
$(formNm).html(data); | |
} | |
}); | |
return false; | |
}); | |
}); | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ($_SERVER["REQUEST_METHOD"] == "POST") { | |
if (isset($_POST['formData'])) {$formData = $_POST['formData'];} | |
if (isset($_POST['email'])) {$email = $_POST['email'];} | |
if (isset($_POST['name'])) {$name = $_POST['name'];} | |
if (isset($_POST['phone'])) {$phone = $_POST['phone'];} | |
if (isset($_POST['message'])) {$message = $_POST['message'];} | |
$to = "[email protected]"; /*Укажите ваш адрес электронной почты*/ | |
$headers = "Content-type: text/plain; charset = utf-8"; | |
$subject = "$formData"; | |
$message = "$formData\n\nОткуда: $email \n\nОтправитель: $name \n\nТелефон: $phone \n\nСообщение: $message"; | |
$send = mail ($to, $subject, $message, $headers); | |
if ($send == 'true') | |
{ | |
echo "<center>Спасибо за отправку вашего сообщения! Наши специалисты свяжутся с вами в течение часа.</center>"; | |
} | |
else | |
{ | |
echo "<center><b>Ошибка. Сообщение не отправлено! Проверьте правильность введенных данных</b></center>"; | |
} | |
} else { | |
http_response_code(403); | |
echo "Попробуйте еще раз"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment