Compare commits
2 Commits
82529bed91
...
0ba1b74876
| Author | SHA1 | Date | |
|---|---|---|---|
| 0ba1b74876 | |||
| 9e006c2572 |
53
index.html
53
index.html
@@ -820,27 +820,62 @@
|
||||
</style>
|
||||
|
||||
<script>
|
||||
// Открытие модального окна
|
||||
document.querySelectorAll('[href="#booking"], .btn[href="#booking"]').forEach(btn => {
|
||||
// === МОДАЛЬНОЕ ОКНО + ОТПРАВКА ===
|
||||
const popup = document.getElementById('booking-popup');
|
||||
const form = document.getElementById('popup-booking-form');
|
||||
|
||||
if (popup && form) {
|
||||
// Открытие окна
|
||||
document.querySelectorAll('a[href="#booking"], .btn[href="#booking"]').forEach(btn => {
|
||||
btn.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
document.getElementById('booking-popup').classList.add('modal--active');
|
||||
popup.classList.add('modal--active');
|
||||
});
|
||||
});
|
||||
|
||||
// Закрытие
|
||||
document.querySelectorAll('[data-modal-close]').forEach(el => {
|
||||
el.addEventListener('click', () => {
|
||||
document.getElementById('booking-popup').classList.remove('modal--active');
|
||||
popup.classList.remove('modal--active');
|
||||
});
|
||||
});
|
||||
|
||||
// Закрытие по Esc
|
||||
document.addEventListener('keydown', e => {
|
||||
if (e.key === "Escape") {
|
||||
document.getElementById('booking-popup').classList.remove('modal--active');
|
||||
}
|
||||
// Отправка формы
|
||||
form.addEventListener('submit', async function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
const submitBtn = form.querySelector('button[type="submit"]');
|
||||
const originalText = submitBtn.textContent;
|
||||
|
||||
submitBtn.textContent = 'Отправляем...';
|
||||
submitBtn.disabled = true;
|
||||
|
||||
const formData = new FormData(form);
|
||||
|
||||
try {
|
||||
const response = await fetch('send-form.php', {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
});
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
if (result.status === "success") {
|
||||
alert("✅ Заявка успешно отправлена!\nМы свяжемся с вами в ближайшее время.");
|
||||
form.reset();
|
||||
popup.classList.remove('modal--active');
|
||||
} else {
|
||||
alert("❌ " + (result.message || "Ошибка при отправке. Попробуйте позже."));
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
alert("❌ Ошибка соединения. Проверьте интернет и попробуйте снова.");
|
||||
}
|
||||
|
||||
submitBtn.textContent = originalText;
|
||||
submitBtn.disabled = false;
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
@@ -1,32 +1,39 @@
|
||||
<?php
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
$name = strip_tags(trim($_POST["name"]));
|
||||
$phone = strip_tags(trim($_POST["phone"]));
|
||||
$email = strip_tags(trim($_POST["email"]));
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
//$to = "receptionadmin@o-arena.ru"; // поменяй на свой реальный email
|
||||
$to = "rid89@mail.ru"; // поменяй на свой реальный email
|
||||
$subject = "Новая заявка с сайта OlimpArena";
|
||||
if ($_SERVER["REQUEST_METHOD"] !== "POST") {
|
||||
echo json_encode(["status" => "error", "message" => "Неверный запрос"]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$message = "Имя: $name\n";
|
||||
$message .= "Телефон: $phone\n";
|
||||
$message .= "Email: $email\n";
|
||||
$message .= "Дата отправки: " . date('d.m.Y H:i') . "\n";
|
||||
$name = trim(strip_tags($_POST["name"] ?? ""));
|
||||
$phone = trim(strip_tags($_POST["phone"] ?? ""));
|
||||
$email = trim(strip_tags($_POST["email"] ?? ""));
|
||||
|
||||
$headers = "From: no-reply@olimparena.aiconversion.ru\r\n";
|
||||
$headers .= "Reply-To: $email\r\n";
|
||||
$headers .= "Content-Type: text/plain; charset=utf-8\r\n";
|
||||
if (empty($name) || empty($phone)) {
|
||||
echo json_encode(["status" => "error", "message" => "Имя и телефон обязательны"]);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (mail($to, $subject, $message, $headers)) {
|
||||
// Можно перенаправить на успех
|
||||
header("Location: index.html#booking-success-modal");
|
||||
// или показать JSON для JS
|
||||
//$to = "receptionadmin@o-arena.ru"; // ← Измени на свой реальный email!
|
||||
$to = "rid89@mail.ru";
|
||||
|
||||
$subject = "Новая заявка с сайта OlimpArena";
|
||||
|
||||
$message = "📩 Новая заявка из всплывающего окна\n\n";
|
||||
$message .= "Имя: $name\n";
|
||||
$message .= "Телефон: $phone\n";
|
||||
$message .= "Email: $email\n\n";
|
||||
$message .= "Дата: " . date('d.m.Y H:i:s') . "\n";
|
||||
|
||||
$headers = "From: no-reply@olimparena.aiconversion.ru\r\n";
|
||||
$headers .= "Reply-To: $email\r\n";
|
||||
$headers .= "Content-Type: text/plain; charset=utf-8\r\n";
|
||||
|
||||
if (mail($to, $subject, $message, $headers)) {
|
||||
echo json_encode(["status" => "success"]);
|
||||
} else {
|
||||
echo json_encode(["status" => "error"]);
|
||||
}
|
||||
} else {
|
||||
http_response_code(403);
|
||||
echo "Доступ запрещён";
|
||||
error_log("Mail error: " . print_r(error_get_last(), true));
|
||||
echo json_encode(["status" => "error", "message" => "Не удалось отправить письмо"]);
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user