87 lines
3.2 KiB
PHP
87 lines
3.2 KiB
PHP
<?php
|
|
// contact.php
|
|
require_once 'includes/auth.php';
|
|
require_once 'includes/header.php';
|
|
global $pdo;
|
|
|
|
$msg = '';
|
|
$inquiry_car = null;
|
|
|
|
if (isset($_GET['inquiry'])) {
|
|
$stmt = $pdo->prepare("SELECT * FROM cars WHERE id = ?");
|
|
$stmt->execute([$_GET['inquiry']]);
|
|
$inquiry_car = $stmt->fetch();
|
|
}
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
// Process form (Demo only - just save to DB or show success)
|
|
$name = $_POST['name'];
|
|
$email = $_POST['email'];
|
|
$message = $_POST['message'];
|
|
$car_id = $_POST['car_id'] ?? null;
|
|
|
|
// Use the built-in mail service if desired, or just save to DB
|
|
// For this "100% offline" task, saving to DB is better.
|
|
|
|
$stmt = $pdo->prepare("INSERT INTO inquiries (car_id, name, email, message) VALUES (?, ?, ?, ?)");
|
|
$stmt->execute([$car_id, $name, $email, $message]);
|
|
|
|
$msg = "Thank you! Your message has been sent. We will contact you shortly.";
|
|
}
|
|
?>
|
|
|
|
<div class="container mt-5">
|
|
<h1>Contact Us</h1>
|
|
<p class="mb-5">We are here to help you find your dream car.</p>
|
|
|
|
<?php if ($msg): ?>
|
|
<div style="background: rgba(42, 157, 143, 0.2); color: #2a9d8f; padding: 20px; border-radius: 10px; margin-bottom: 30px;">
|
|
<?= htmlspecialchars($msg) ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<div class="grid" style="grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 50px;">
|
|
<div>
|
|
<form method="POST">
|
|
<?php if ($inquiry_car): ?>
|
|
<div style="background: rgba(255,255,255,0.05); padding: 15px; border-radius: 5px; margin-bottom: 20px;">
|
|
<strong>Inquiry about:</strong> <?= htmlspecialchars($inquiry_car['year'] . ' ' . $inquiry_car['brand'] . ' ' . $inquiry_car['model']) ?>
|
|
<input type="hidden" name="car_id" value="<?= $inquiry_car['id'] ?>">
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<div class="form-group">
|
|
<label>Your Name</label>
|
|
<input type="text" name="name" class="form-control" required>
|
|
</div>
|
|
<div class="form-group">
|
|
<label>Email Address</label>
|
|
<input type="email" name="email" class="form-control" required>
|
|
</div>
|
|
<div class="form-group">
|
|
<label>Message</label>
|
|
<textarea name="message" class="form-control" rows="5" required><?= $inquiry_car ? "I am interested in this vehicle. Please provide more details." : "" ?></textarea>
|
|
</div>
|
|
<button type="submit" class="btn">Send Message</button>
|
|
</form>
|
|
</div>
|
|
|
|
<div>
|
|
<h3>Head Office</h3>
|
|
<p class="mb-5">Shar-e-Naw, Kabul, Afghanistan</p>
|
|
|
|
<h3>Phone</h3>
|
|
<p class="mb-5">+93 700 000 000</p>
|
|
|
|
<h3>Email</h3>
|
|
<p class="mb-5">info@afgcars.af</p>
|
|
|
|
<h3>Hours</h3>
|
|
<p>Sat - Thu: 8:00 AM - 6:00 PM</p>
|
|
<p>Friday: Closed</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php require_once 'includes/footer.php'; ?>
|