38468-vm/contact.php
Flatlogic Bot f65de53240 sadiq
2026-02-16 05:06:25 +00:00

95 lines
4.5 KiB
PHP

<?php
require_once 'db/config.php';
require_once 'mail/MailService.php';
$success = '';
$error = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$name = htmlspecialchars($_POST['name'] ?? '');
$email = htmlspecialchars($_POST['email'] ?? '');
$subject = htmlspecialchars($_POST['subject'] ?? '');
$message = htmlspecialchars($_POST['message'] ?? '');
if (empty($name) || empty($email) || empty($message)) {
$error = 'Please fill in all required fields.';
} elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$error = 'Please enter a valid email address.';
} else {
try {
$stmt = db()->prepare("INSERT INTO contact_messages (name, email, subject, message) VALUES (?, ?, ?, ?)");
$stmt->execute([$name, $email, $subject, $message]);
// Send email using MailService
$res = MailService::sendContactMessage($name, $email, $message);
$success = 'Thank you for your message! We will get back to you soon.';
} catch (PDOException $e) {
$error = 'An error occurred while sending your message. Please try again later.';
}
}
}
include 'includes/header.php';
?>
<main class="container mt-4">
<div class="row justify-between align-center">
<div class="col-6">
<h1 class="section-title">Get in Touch</h1>
<p class="mb-4" style="color: var(--text-muted);">Have questions about a car or want to list your own? Our team in Kabul is ready to help you 24/7.</p>
<div class="glass-card mb-4">
<h3 class="text-gold mb-4">Contact Information</h3>
<p><strong>Email:</strong> admin@gmail.com</p>
<p><strong>Location:</strong> Kabul, Afghanistan</p>
<p><strong>Developer:</strong> Mohammad Sadiq</p>
</div>
</div>
<div class="col-6">
<div class="glass-card">
<h2 class="mb-4">Send a Message</h2>
<?php if ($success): ?>
<div style="background: rgba(40, 167, 69, 0.2); border: 1px solid #28a745; color: #28a745; padding: 15px; border-radius: var(--radius-md); margin-bottom: 20px;">
<?php echo $success; ?>
</div>
<?php endif; ?>
<?php if ($error): ?>
<div style="background: rgba(220, 53, 69, 0.2); border: 1px solid #dc3545; color: #dc3545; padding: 15px; border-radius: var(--radius-md); margin-bottom: 20px;">
<?php echo $error; ?>
</div>
<?php endif; ?>
<form method="POST" action="contact.php">
<div class="mb-4">
<label style="display: block; margin-bottom: 8px;">Full Name *</label>
<input type="text" name="name" required style="width: 100%; padding: 12px; background: rgba(255,255,255,0.05); border: 1px solid var(--glass-border); border-radius: var(--radius-md); color: white;">
</div>
<div class="mb-4">
<label style="display: block; margin-bottom: 8px;">Email Address *</label>
<input type="email" name="email" required style="width: 100%; padding: 12px; background: rgba(255,255,255,0.05); border: 1px solid var(--glass-border); border-radius: var(--radius-md); color: white;">
</div>
<div class="mb-4">
<label style="display: block; margin-bottom: 8px;">Subject</label>
<input type="text" name="subject" style="width: 100%; padding: 12px; background: rgba(255,255,255,0.05); border: 1px solid var(--glass-border); border-radius: var(--radius-md); color: white;">
</div>
<div class="mb-4">
<label style="display: block; margin-bottom: 8px;">Message *</label>
<textarea name="message" rows="5" required style="width: 100%; padding: 12px; background: rgba(255,255,255,0.05); border: 1px solid var(--glass-border); border-radius: var(--radius-md); color: white;"></textarea>
</div>
<button type="submit" class="btn btn-primary w-100">Send Message</button>
</form>
</div>
</div>
</div>
</main>
<?php include 'includes/footer.php'; ?>