48 lines
1.9 KiB
PHP
48 lines
1.9 KiB
PHP
<?php
|
|
$message = '';
|
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
|
require_once __DIR__ . '/mail/MailService.php';
|
|
$name = filter_var($_POST['name'], FILTER_SANITIZE_STRING);
|
|
$email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);
|
|
$body = filter_var($_POST['message'], FILTER_SANITIZE_STRING);
|
|
|
|
$result = MailService::sendContactMessage($name, $email, $body);
|
|
|
|
if (!empty($result['success'])) {
|
|
$message = '<div class="alert alert-success">Thank you for your message. We will get back to you shortly.</div>';
|
|
} else {
|
|
$message = '<div class="alert alert-danger">Sorry, there was an error sending your message. Please try again later.</div>';
|
|
}
|
|
}
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Contact Us</title>
|
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
|
|
</head>
|
|
<body>
|
|
<div class="container mt-5">
|
|
<h1>Contact Us</h1>
|
|
<p>Fill out the form below to get in touch with us.</p>
|
|
<?php if ($message) echo $message; ?>
|
|
<form action="contact.php" method="post">
|
|
<div class="form-group">
|
|
<label for="name">Name</label>
|
|
<input type="text" class="form-control" id="name" name="name" required>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="email">Email address</label>
|
|
<input type="email" class="form-control" id="email" name="email" required>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="message">Message</label>
|
|
<textarea class="form-control" id="message" name="message" rows="5" required></textarea>
|
|
</div>
|
|
<button type="submit" class="btn btn-primary">Submit</button>
|
|
</form>
|
|
</div>
|
|
</body>
|
|
</html>
|