filename:
views/public/contact.php
branch:
main
back to repo
<?php
$pageTitle = "Contact – Seven O'Clock Dinner";
$errors = [];
$successMessage = null;
if (($_SERVER['REQUEST_METHOD'] ?? 'GET') === 'POST') {
$name = trim($_POST['name'] ?? '');
$email = trim($_POST['email'] ?? '');
$message = trim($_POST['message'] ?? '');
if ($name === '' || $email === '' || $message === '') {
$errors[] = 'Please complete all contact fields.';
} elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$errors[] = 'Please provide a valid email for contact.';
} else {
$stmt = $db->prepare('INSERT INTO contact_messages (name, email, message) VALUES (?, ?, ?)');
$stmt->bind_param('sss', $name, $email, $message);
$stmt->execute();
$successMessage = 'Your note has been received. We will be in touch.';
}
}
?>
<div class="page-grid">
<div class="card" data-animate-initial>
<div class="muted" style="font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; margin-bottom: 10px;">
Contact
</div>
<h1 style="font-family: 'Georgia', 'Times New Roman', serif; font-weight: 400; font-size: 26px; margin: 0 0 12px;">
Feedback, questions, or whatever.
</h1>
<?php if ($errors): ?>
<ul style="margin-top: 16px; padding-left: 18px; color: #9b2c2c; font-size: 13px;">
<?php foreach ($errors as $err): ?>
<li><?= htmlspecialchars($err, ENT_QUOTES, 'UTF-8') ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<?php if ($successMessage): ?>
<p style="margin-top: 14px; font-size: 13px; color: #22543d;">
<?= htmlspecialchars($successMessage, ENT_QUOTES, 'UTF-8') ?>
</p>
<?php endif; ?>
</div>
<div class="card" data-animate>
<form method="post" style="display: grid; gap: 10px; font-size: 13px;">
<label>
Name<br>
<input name="name" type="text" required style="width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid rgba(0,0,0,0.12); background: rgba(255,255,255,0.8);">
</label>
<label>
Email<br>
<input name="email" type="email" required style="width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid rgba(0,0,0,0.12); background: rgba(255,255,255,0.8);">
</label>
<label>
Message<br>
<textarea name="message" rows="4" required style="width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid rgba(0,0,0,0.12); background: rgba(255,255,255,0.8);"></textarea>
</label>
<button type="submit" class="pill" style="margin-top: 6px; justify-content: center;">
Send note
</button>
</form>
</div>
</div>