148 lines
7.6 KiB
PHP
148 lines
7.6 KiB
PHP
<?php
|
||
$success_message = '';
|
||
$error_message = '';
|
||
$name = '';
|
||
$email = '';
|
||
$message = '';
|
||
|
||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||
// Ensure MailService is included. The path is relative to the current file.
|
||
require_once __DIR__ . '/mail/MailService.php';
|
||
|
||
// Sanitize and retrieve form data
|
||
$name = filter_var(trim($_POST['name']), FILTER_SANITIZE_STRING);
|
||
$email = filter_var(trim($_POST['email']), FILTER_SANITIZE_EMAIL);
|
||
$message = filter_var(trim($_POST['message']), FILTER_SANITIZE_STRING);
|
||
|
||
// Basic validation
|
||
if (empty($name) || !filter_var($email, FILTER_VALIDATE_EMAIL) || empty($message)) {
|
||
$error_message = 'Iltimos, barcha maydonlarni to‘g‘ri to‘ldiring.';
|
||
} else {
|
||
// Set the recipient email address.
|
||
// For now, we let MailService use the default from .env
|
||
$to = null;
|
||
$subject = 'Maktab saytidan yangi xabar: ' . $name;
|
||
|
||
// Call the MailService to send the email
|
||
$res = MailService::sendContactMessage($name, $email, $message, $to, $subject);
|
||
|
||
if (!empty($res['success'])) {
|
||
$success_message = 'Xabaringiz muvaffaqiyatli yuborildi. Tez orada siz bilan bog‘lanamiz!';
|
||
// Clear form fields on success
|
||
$name = '';
|
||
$email = '';
|
||
$message = '';
|
||
} else {
|
||
// Log the actual error for the admin, but show a generic message to the user.
|
||
error_log('MailService error: ' . ($res['error'] ?? 'Unknown error'));
|
||
$error_message = 'Xabarni yuborishda xatolik yuz berdi. Iltimos, keyinroq qayta urinib ko‘ring yoki administrator bilan bog‘laning.';
|
||
}
|
||
}
|
||
}
|
||
?>
|
||
<!DOCTYPE html>
|
||
<html lang="uz">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title>Bog‘lanish - Maktab Nomi</title>
|
||
<meta name="description" content="Biz bilan bog‘laning. Savol, taklif yoki fikrlaringizni yuboring.">
|
||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@700&family=Lato:wght@400;700&display=swap" rel="stylesheet">
|
||
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||
</head>
|
||
<body>
|
||
|
||
<header class="bg-primary text-white py-3">
|
||
<div class="container d-flex justify-content-between align-items-center">
|
||
<a href="index.php" class="text-white text-decoration-none"><h1 class="h3 mb-0">Maktab Nomi</h1></a>
|
||
<nav>
|
||
<ul class="nav">
|
||
<li class="nav-item"><a class="nav-link text-white" href="index.php">Bosh sahifa</a></li>
|
||
<li class="nav-item"><a class="nav-link text-white" href="index.php#about">Biz haqimizda</a></li>
|
||
<li class="nav-item"><a class="nav-link text-white" href="index.php#teachers">O‘qituvchilar</a></li>
|
||
<li class="nav-item"><a class="nav-link text-white" href="index.php#news">Yangiliklar</a></li>
|
||
<li class="nav-item"><a class="nav-link text-white active" href="contact.php">Bog‘lanish</a></li>
|
||
</ul>
|
||
</nav>
|
||
</div>
|
||
</header>
|
||
|
||
<main class="container my-5">
|
||
<div class="row justify-content-center">
|
||
<div class="col-lg-8">
|
||
<div class="card shadow-sm">
|
||
<div class="card-body p-5">
|
||
<h2 class="text-center mb-4">Biz bilan bog‘lanish</h2>
|
||
<p class="text-center text-muted mb-5">Savol, taklif yoki hamkorlik uchun quyidagi formani to‘ldiring.</p>
|
||
|
||
<?php if ($success_message): ?>
|
||
<div class="alert alert-success"><?php echo $success_message; ?></div>
|
||
<?php endif; ?>
|
||
<?php if ($error_message): ?>
|
||
<div class="alert alert-danger"><?php echo $error_message; ?></div>
|
||
<?php endif; ?>
|
||
|
||
<div class="alert alert-warning">
|
||
<strong>Diqqat:</strong> Bu test rejimida ishlamoqda. Xabarlar belgilangan manzilga yetib bormasligi mumkin. Iltimos, administrator sozlamalarni to'g'rilaguncha kutib turing.
|
||
</div>
|
||
|
||
<form action="contact.php" method="POST">
|
||
<div class="mb-3">
|
||
<label for="name" class="form-label">To‘liq ismingiz</label>
|
||
<input type="text" class="form-control" id="name" name="name" value="<?php echo htmlspecialchars($name); ?>" required>
|
||
</div>
|
||
<div class="mb-3">
|
||
<label for="email" class="form-label">Email manzilingiz</label>
|
||
<input type="email" class="form-control" id="email" name="email" value="<?php echo htmlspecialchars($email); ?>" required>
|
||
</div>
|
||
<div class="mb-3">
|
||
<label for="message" class="form-label">Xabar matni</label>
|
||
<textarea class="form-control" id="message" name="message" rows="5" required><?php echo htmlspecialchars($message); ?></textarea>
|
||
</div>
|
||
<div class="text-center">
|
||
<button type="submit" class="btn btn-primary btn-lg px-5">Yuborish</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</main>
|
||
|
||
<footer id="contact" class="bg-dark text-white pt-5 pb-4">
|
||
<div class="container text-center text-md-start">
|
||
<div class="row text-center text-md-start">
|
||
<div class="col-md-3 col-lg-3 col-xl-3 mx-auto mt-3">
|
||
<h5 class="text-uppercase mb-4 font-weight-bold text-primary">Maktab Nomi</h5>
|
||
<p>Bizning maktabimizda farzandingiz uchun yorqin kelajak, sifatli ta’lim va xavfsiz muhitni ta’minlaymiz.</p>
|
||
</div>
|
||
|
||
<div class="col-md-3 col-lg-2 col-xl-2 mx-auto mt-3">
|
||
<h5 class="text-uppercase mb-4 font-weight-bold text-primary">Tezkor havolalar</h5>
|
||
<p><a href="index.php#about" class="text-white">Biz haqimizda</a></p>
|
||
<p><a href="index.php#news" class="text-white">Yangiliklar</a></p>
|
||
<p><a href="index.php#teachers" class="text-white">O‘qituvchilar</a></p>
|
||
</div>
|
||
|
||
<div class="col-md-4 col-lg-3 col-xl-3 mx-auto mt-3">
|
||
<h5 class="text-uppercase mb-4 font-weight-bold text-primary">Bog‘lanish</h5>
|
||
<p><i class="fas fa-home me-3"></i> O‘zbekiston, Toshkent, Mustaqillik k., 1</p>
|
||
<p><i class="fas fa-envelope me-3"></i> info@maktab.uz</p>
|
||
<p><i class="fas fa-phone me-3"></i> +998 71 234 56 78</p>
|
||
</div>
|
||
</div>
|
||
<hr class="my-4">
|
||
<div class="text-center">
|
||
<p>© <?php echo date("Y"); ?> Maktab Nomi. Barcha huquqlar himoyalangan.</p>
|
||
</div>
|
||
</div>
|
||
</footer>
|
||
|
||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
|
||
</body>
|
||
</html>
|