diff --git a/src/controllers/Contact.php b/src/controllers/Contact.php index 2e9c577..cacb756 100644 --- a/src/controllers/Contact.php +++ b/src/controllers/Contact.php @@ -26,6 +26,8 @@ public function __construct() $this->view_data['defaultEmail'] = ""; $this->view_data['defaultMessage'] = ""; $this->view_data['errors'] = []; + $this->view_data['contact_us_successful'] = false; + } /** @@ -84,7 +86,7 @@ private function handleFormSubmission(): void if (empty($this->view_data['errors'])) { $success = $this->mailBusinessInbox($form_data); if ($success) { - Utility::redirect('home'); + $this->view_data['contact_us_successful'] = true; } else { (new Error())->handleMailingError(); } @@ -100,18 +102,18 @@ private function handleFormSubmission(): void */ private function mailBusinessInbox($form_data): bool { - // Concatenate form data into the email message - $htmlMessage = "You have received a new message from:
"; - $htmlMessage .= "Name: " . $form_data['first_name'] . " " . $form_data['last_name'] . "
"; - $htmlMessage .= "Email: " . $form_data['email'] . "
"; - $htmlMessage .= "Message: " . $form_data['message'] . "
"; + // Load the email template + ob_start(); + extract($form_data); + include __DIR__ . '/../views/mails/Contact.php'; + $htmlMessage = ob_get_clean(); $plainMessage = "You have received a new message from:\n"; $plainMessage .= "Name: " . $form_data['first_name'] . " " . $form_data['last_name'] . "\n"; $plainMessage .= "Email: " . $form_data['email'] . "\n"; $plainMessage .= "Message: " . $form_data['message'] . "\n"; - //Implement logic to send email to admin using Mailer class + // Implement logic to send email to admin using Mailer class $mailer = new Mailer(); $subject = "New Contact Message from " . $form_data['first_name'] . " " . $form_data['last_name']; diff --git a/src/views/Contact.php b/src/views/Contact.php index c524d51..8a242a2 100644 --- a/src/views/Contact.php +++ b/src/views/Contact.php @@ -45,4 +45,14 @@ - \ No newline at end of file + + +> +
+

Thank You for Contacting Us! 🔎

+

Your message has been successfully sent. Our team will review your inquiry and get back to you shortly. We appreciate your interest in our services.

+ +
+
\ No newline at end of file diff --git a/src/views/mails/Contact.php b/src/views/mails/Contact.php new file mode 100644 index 0000000..3bf7c33 --- /dev/null +++ b/src/views/mails/Contact.php @@ -0,0 +1,51 @@ + + + + + + + New Contact Message + + + +
+

New Contact Message

+

Name:

+

Email:

+

Message:

+

+ +
+ +