movmaker-webui/contact.php.example
2026-06-20 16:13:40 +02:00

90 lines
4.5 KiB
Text

<?php
$config = require __DIR__ . "/config.php";
function h($s){ return htmlspecialchars((string)$s, ENT_QUOTES, "UTF-8"); }
$msg = '';
$err = '';
$form_name = '';
$form_email = '';
$form_message = '';
// ##################################################################
// ## IMPORTANT: Replace this with your actual email address. ##
// ##################################################################
$to_email = 'Bubulescu.Org <mail@mail.com>';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$form_name = trim((string)($_POST['name'] ?? ''));
$form_email = trim((string)($_POST['email'] ?? ''));
$form_message = trim((string)($_POST['message'] ?? ''));
$honeypot = trim((string)($_POST['website'] ?? ''));
if ($honeypot !== '') {
// This was likely a bot, fail silently but look like a success.
$msg = "Thank you for your message!";
} elseif ($form_name === '' || $form_email === '' || $form_message === '') {
$err = "Please fill out all required fields.";
} elseif (!filter_var($form_email, FILTER_VALIDATE_EMAIL)) {
$err = "Please provide a valid email address.";
} else {
$subject = "MVLog Contact Submission from " . $form_name;
$body = "Name: " . $form_name . "\n";
$body .= "Email: " . $form_email . "\n\n";
$body .= "Message:\n" . str_replace(["\r\n", "\r"], "\n", $form_message);
$headers = "From: " . $form_name . " <" . $form_email . ">\r\n";
$headers .= "Reply-To: " . $form_email . "\r\n";
$headers .= "X-Mailer: PHP/" . phpversion();
if (mail($to_email, $subject, $body, $headers)) {
$msg = "Thank you for your message! I will get back to you shortly.";
$form_name = $form_email = $form_message = ''; // Clear form on success
} else {
$err = "Sorry, there was an error sending your message. Please try again later.";
}
}
}
$headerTitles = [ 'Moto Vlog', 'Multiple Voices Log', 'Multi-Version Log', 'MultiVerse Log', 'Miles & Views Log', 'Moving Vistas Log', 'Motorcycle Voyage Log', 'Mapped Vagabond Log', 'Mountain Valley Log', 'Miles Versus Logic', 'Motorcycle Voyage Log', 'Mapped Vagabond Log', 'Multiple Viewpoints Log', 'Multiple Versions of Life', 'Motion, Velocity & Luck', 'Miles, Views & Life', 'Many Voices of Life', 'Many Views of Life', 'Modern Vagabond Log', 'Motorcycle Wanderlust Log', 'Mapped Wanderings Log', 'Miles Beyond Reason', 'Miles Beyond Reality', 'Motion, Velocity & Lunacy', 'Miles, Wind & Luck', 'Maps, Villages & Legends', 'Multi-Vision Log', 'Multi-Vista Log', 'Mutable View Log', 'Mistakes, Victories & Lessons', 'Mostly Verified Legends', 'Mostly Vague Logistics', 'Marginally Viable Leadership', 'Mileage Versus Luck', 'Mechanical Violence Log', 'Moderately Violent Leisure', 'Mistakes Validated Later', ];
$siteHeaderTitle = $headerTitles[array_rand($headerTitles)];
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>MVL - Contact</title>
<?php include __DIR__ . '/_pwa_head.php'; ?>
<meta property="og:title" content="MVLog: journal of an unreliable narrator.">
<meta property="og:description" content="Motorcycle road stories, hockey passion, pizza nerdism and facts remembered by an unreliable narrator.">
<meta property="og:image" content="https://bubulescu.org/assets/img/moto_travel.png">
<meta property="og:url" content="https://bubulescu.org">
<link rel="icon" type="image/png" href="assets/img/moto_travel.png">
<link rel="stylesheet" href="style.css?v=20260531k">
</head>
<body>
<?php include __DIR__ . '/_header.php'; ?>
<main>
<section class="contact-form-section">
<h2>Contact</h2>
<?php if($msg): ?><div class="ok"><?=h($msg)?></div><?php endif; ?>
<?php if($err): ?><div class="err"><?=h($err)?></div><?php endif; ?>
<form method="post" action="contact.php" id="contact-form">
<label>Name*<input type="text" name="name" value="<?=h($form_name)?>" required></label>
<label>Email*<input type="email" name="email" value="<?=h($form_email)?>" required></label>
<label>Message*<textarea name="message" required><?=h($form_message)?></textarea></label>
<!-- Honeypot field for spam bots -->
<div style="position: absolute; left: -5000px;" aria-hidden="true">
<label>Don't fill this out if you're human: <input type="text" name="website" tabindex="-1" autocomplete="off"></label>
</div>
<button type="submit">Send Message</button>
</form>
</section>
</main>
<?php include __DIR__ . '/_footer.php'; ?>
</body>
</html>