Last active
September 4, 2022 20:29
-
-
Save Mons1eurEnzo/3665398d9e20a8bdd7967d6f1d62d7d6 to your computer and use it in GitHub Desktop.
html, php, jQuery(AJAX) - Форма обратной связи
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
$(document).ready(function() { | |
$("#form").submit(function() { | |
$.ajax({ | |
type: "POST", | |
url: "mail.php", | |
data: $(this).serialize() | |
}).done(function() { | |
$(this).find("input").val(""); | |
alert("Спасибо за заявку! Скоро мы с вами свяжемся."); | |
$("#form").trigger("reset"); | |
}); | |
return false; | |
}); | |
}); |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Отправка форм AJAX</title> | |
</head> | |
<body> | |
<form id="form"> | |
<input type="text" name="name" placeholder="Ваше имя" required /><br /> | |
<input type="text" name="phone" placeholder="Ваш телефон" required /><br /> | |
<button>Отправить</button> | |
</form> | |
<script src="https://code.jquery.com/jquery-1.11.2.min.js"></script> | |
<script src="common.js"></script> | |
</body> | |
</html> |
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 | |
$recepient = "agragregra@ya.ru"; | |
$sitename = "Название сайта"; | |
$name = trim($_POST["name"]); | |
$phone = trim($_POST["phone"]); | |
$text = trim($_POST["text"]); | |
$message = "Имя: $name \nТелефон: $phone \nТекст: $text"; | |
$pagetitle = "Новая заявка с сайта \"$sitename\""; | |
mail($recepient, $pagetitle, $message, "Content-type: text/plain; charset=\"utf-8\"\n From: $recepient"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment