aboutsummaryrefslogtreecommitdiff
path: root/controllers/mail.controller.php
diff options
context:
space:
mode:
Diffstat (limited to 'controllers/mail.controller.php')
-rw-r--r--controllers/mail.controller.php38
1 files changed, 38 insertions, 0 deletions
diff --git a/controllers/mail.controller.php b/controllers/mail.controller.php
new file mode 100644
index 0000000..f850ed7
--- /dev/null
+++ b/controllers/mail.controller.php
@@ -0,0 +1,38 @@
+<?php
+
+$submit = new Form();
+
+$submit->name = $_POST['26471'];
+$submit->email = $_POST['26472'];
+$submit->message = $_POST['26478'];
+
+$spam = false;
+
+if (isset($_POST['contact'])) {
+ $spam = $_POST['contact'];
+}
+
+if ((bool) $spam == true) {
+ http_response_code(403);
+ error_log('Contact Form Spam: Error 403');
+ return;
+}
+
+if ((bool) empty($submit->name) == true
+ || (bool) empty($submit->email) == true
+ || (bool) empty($submit->message) == true
+) {
+ header('Location: /contact');
+ return;
+} else {
+ include '../views/sent.view.php';
+ fastcgi_finish_request();
+ $contact['database']->insert(
+ 'contactform', [
+ 'name' => $submit->name,
+ 'email' => $submit->email,
+ 'message' => $submit->message,
+ ]
+ );
+ sendMail($submit->name, $submit->email, $submit->message);
+}