From 4fdc2cf068090e38eda360728db64b518bb1ab13 Mon Sep 17 00:00:00 2001
From: Skylar Ittner
Date: Sat, 19 May 2018 01:02:54 -0600
Subject: [PATCH] Add nice messages for contact form error and submission
(close #30)
---
public/contact.php | 29 +++++++++++++++++++++++++----
1 file changed, 25 insertions(+), 4 deletions(-)
diff --git a/public/contact.php b/public/contact.php
index b01611e..074fd1b 100644
--- a/public/contact.php
+++ b/public/contact.php
@@ -7,15 +7,30 @@
require __DIR__ . "/../lib/requiredpublic.php";
-if (empty($_POST['name']) || empty($_POST['message']) || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
+function output_card($content) {
?>
Contact Form
- Whoops! You didn't fill out the contact form properly. Go back and try again.
+
+
Whoops! You didn't fill out the contact form properly.
+Go back and try again.
+END;
+ output_card($content);
+ die();
}
$database->insert("messages", [
@@ -26,4 +41,10 @@ $database->insert("messages", [
"date" => date("Y-m-d H:i:s")
]);
-header('Location: ./');
+$content = <<Thanks!
+Your message has been sent!
+Continue
+END;
+
+output_card($content);
\ No newline at end of file