35710-vm/contact.php
Flatlogic Bot 7a219bcd94 Kotkakey
2025-11-14 10:21:25 +00:00

107 lines
4.7 KiB
PHP

<?php
$success = false;
$error = false;
$name = '';
$email = '';
$message = '';
if ($_SERVER["REQUEST_METHOD"] == "POST") {
require_once __DIR__ . '/mail/MailService.php';
$name = trim($_POST['name'] ?? '');
$email = trim($_POST['email'] ?? '');
$message = trim($_POST['message'] ?? '');
if (empty($name) || empty($email) || empty($message)) {
$error = "All fields are required.";
} elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$error = "Invalid email format.";
} else {
$to = getenv('MAIL_TO') ?: 'info@kotkakey.com';
$res = MailService::sendContactMessage($name, $email, $message, $to, 'Contact Form Submission');
if (!empty($res['success'])) {
header("Location: thank-you.php");
exit;
} else {
$error = "Sorry, there was an error sending your message. Please try again later.";
// Log the detailed error for debugging: error_log('MailService Error: ' . ($res['error'] ?? 'Unknown error'));
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Contact Us - Kotkakey</title>
<meta name="description" content="Get in touch with the Kotkakey team.">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
</head>
<body>
<header class="bg-white shadow-sm">
<nav class="navbar navbar-expand-lg navbar-light">
<div class="container">
<a class="navbar-brand" href="index.php">
<img src="assets/pasted-20251114-095035-cf5716ad.png" alt="Kotkakey Logo" height="40">
</a>
<div class="ms-auto">
<span class="navbar-text me-3">EN / FI</span>
</div>
</div>
</nav>
</header>
<main>
<section class="section">
<div class="container">
<div class="row justify-content-center">
<div class="col-lg-8">
<div class="card p-4 p-md-5">
<h1 class="text-center mb-4">Contact Us</h1>
<p class="text-center text-muted mb-4">Have a question or want to learn more? Fill out the form below and we'll get back to you shortly.</p>
<?php if ($error): ?>
<div class="alert alert-danger"><?php echo htmlspecialchars($error); ?></div>
<?php endif; ?>
<form action="contact.php" method="POST">
<div class="mb-3">
<label for="name" class="form-label">Full Name</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 Address</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">Message</label>
<textarea class="form-control" id="message" name="message" rows="5" required><?php echo htmlspecialchars($message); ?></textarea>
</div>
<div class="d-grid">
<button type="submit" class="btn btn-primary btn-lg">Send Message</button>
</div>
</form>
</div>
</div>
</div>
</div>
</section>
</main>
<footer class="py-4 bg-dark text-white mt-auto">
<div class="container text-center">
<p>Email: <a href="mailto:info@kotkakey.com" class="text-white">info@kotkakey.com</a> | <a href="https://www.linkedin.com/company/kotkakey" class="text-white">LinkedIn</a></p>
<p><a href="#" class="text-white">Privacy Policy</a> | GDPR Compliant</p>
<small>&copy; <?php echo date("Y"); ?> Kotkakey. All Rights Reserved.</small>
</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>