0.3
This commit is contained in:
parent
bbfb8cc347
commit
dda0d39a08
25
contact.php
25
contact.php
@ -2,8 +2,6 @@
|
||||
session_start();
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
require_once 'db/config.php';
|
||||
|
||||
$name = trim($_POST['name']);
|
||||
$email = trim($_POST['email']);
|
||||
$message = trim($_POST['message']);
|
||||
@ -14,21 +12,16 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
exit();
|
||||
}
|
||||
|
||||
try {
|
||||
$pdo = db();
|
||||
$sql = "INSERT INTO contact_submissions (name, email, message) VALUES (?, ?, ?)";
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([$name, $email, $message]);
|
||||
require_once 'mail/MailService.php';
|
||||
$mailResult = MailService::sendContactMessage($name, $email, $message, 'vo.info.contact@gmail.com');
|
||||
|
||||
if (!empty($mailResult['success'])) {
|
||||
$_SESSION['success'] = "Thank you for your message. We will get back to you shortly.";
|
||||
|
||||
// Optionally send an email notification
|
||||
require_once 'mail/MailService.php';
|
||||
MailService::sendContactMessage($name, $email, $message, 'vo.info.contact@gmail.com');
|
||||
|
||||
} catch (PDOException $e) {
|
||||
// In a real app, you would log this error
|
||||
$_SESSION['error'] = "Sorry, there was an error submitting your message. Please try again later.";
|
||||
} else {
|
||||
$_SESSION['error'] = "Sorry, there was an error sending your message. Please try again later.";
|
||||
if (!empty($mailResult['error'])) {
|
||||
error_log("MailService Error: " . $mailResult['error']);
|
||||
}
|
||||
}
|
||||
|
||||
header("Location: /#contact");
|
||||
@ -36,4 +29,4 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
} else {
|
||||
header("Location: /");
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user