From bf2f5b3bde8db646bf120e455c20c66997ece1c0 Mon Sep 17 00:00:00 2001 From: muli Date: Wed, 3 Aug 2022 19:31:06 +0200 Subject: [PATCH] feat: Added subject to contact form. --- assets/css/style.css | 1 + assets/js/contact_form.js | 2 ++ assets/php/contact_form.php | 3 ++- templates/contact_page.html | 4 ++++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/assets/css/style.css b/assets/css/style.css index a3c0ee0..d783b17 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -911,6 +911,7 @@ hr.-even { height: 12em; } +.contact_form__subject, .contact_form__message, .contact_form__name, .contact_form__email, diff --git a/assets/js/contact_form.js b/assets/js/contact_form.js index fb0844b..fcd7540 100644 --- a/assets/js/contact_form.js +++ b/assets/js/contact_form.js @@ -1,6 +1,7 @@ const ajaxUrl = 'https://spielwiese.wtf-eg.de/php/contact_form.php'; // const submit_button = document.getElementsByClassName('contact_form__submit_button')[0]; const contact_form = document.getElementsByClassName('content__contact_form')[0]; +const subject = document.getElementsByClassName('contact_form__subject')[0]; const message = document.getElementsByClassName('contact_form__message')[0]; const name = document.getElementsByClassName('contact_form__name')[0]; const email = document.getElementsByClassName('contact_form__email')[0]; @@ -26,6 +27,7 @@ contact_form.addEventListener('submit', function(event) { event.preventDefault(); let formData = new FormData(); formData.append('action', 'handle_form'); + formData.append('subject', subject.value); formData.append('message', message.value); formData.append('name', name.value); formData.append('email', email.value); diff --git a/assets/php/contact_form.php b/assets/php/contact_form.php index 205c11b..88d2497 100644 --- a/assets/php/contact_form.php +++ b/assets/php/contact_form.php @@ -63,11 +63,12 @@ function prepare_response() { $response['errors'][] = 'Wir glauben du bist ein Bot.'; } if (!array_key_exists('errors', $response)) { + $subject = sanitize_text('subject'); $message = sanitize_text('message'); $name = sanitize_text('name'); $email = sanitize_text('email'); - if (!send_message_to_office($message, $name, $email)) { + if (!send_message_to_office($subject, $message, $name, $email)) { $response['errors'][] = 'Deine Nachricht konnte nicht übermittelt werden.'; } else { $response['status'] = 'ok'; diff --git a/templates/contact_page.html b/templates/contact_page.html index 0e128ce..f90a682 100644 --- a/templates/contact_page.html +++ b/templates/contact_page.html @@ -25,6 +25,10 @@ Deine E-Mail-Adresse wird nicht veröffentlicht.

+

+ + +