This commit is contained in:
Flatlogic Bot 2025-10-27 20:13:31 +00:00
parent bbfb8cc347
commit dda0d39a08

View File

@ -2,8 +2,6 @@
session_start(); session_start();
if ($_SERVER["REQUEST_METHOD"] == "POST") { if ($_SERVER["REQUEST_METHOD"] == "POST") {
require_once 'db/config.php';
$name = trim($_POST['name']); $name = trim($_POST['name']);
$email = trim($_POST['email']); $email = trim($_POST['email']);
$message = trim($_POST['message']); $message = trim($_POST['message']);
@ -14,21 +12,16 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
exit(); exit();
} }
try { require_once 'mail/MailService.php';
$pdo = db(); $mailResult = MailService::sendContactMessage($name, $email, $message, 'vo.info.contact@gmail.com');
$sql = "INSERT INTO contact_submissions (name, email, message) VALUES (?, ?, ?)";
$stmt = $pdo->prepare($sql);
$stmt->execute([$name, $email, $message]);
if (!empty($mailResult['success'])) {
$_SESSION['success'] = "Thank you for your message. We will get back to you shortly."; $_SESSION['success'] = "Thank you for your message. We will get back to you shortly.";
} else {
// Optionally send an email notification $_SESSION['error'] = "Sorry, there was an error sending your message. Please try again later.";
require_once 'mail/MailService.php'; if (!empty($mailResult['error'])) {
MailService::sendContactMessage($name, $email, $message, 'vo.info.contact@gmail.com'); error_log("MailService Error: " . $mailResult['error']);
}
} 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.";
} }
header("Location: /#contact"); header("Location: /#contact");