From dda0d39a08cfcf5bb9e63d8890bc22148a6640c3 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Mon, 27 Oct 2025 20:13:31 +0000 Subject: [PATCH] 0.3 --- contact.php | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/contact.php b/contact.php index 18aabc0..c17e9bc 100644 --- a/contact.php +++ b/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(); -} \ No newline at end of file +}