feat: Added subject to contact form.

This commit is contained in:
muli 2022-08-03 19:31:06 +02:00
parent fb90e4933c
commit bf2f5b3bde
4 changed files with 9 additions and 1 deletions

View File

@ -911,6 +911,7 @@ hr.-even {
height: 12em;
}
.contact_form__subject,
.contact_form__message,
.contact_form__name,
.contact_form__email,

View File

@ -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);

View File

@ -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';

View File

@ -25,6 +25,10 @@
Deine E-Mail-Adresse wird nicht veröffentlicht.<br>
<span aria-hidden="true">Erforderliche Felder sind gekennzeichnet <span class="contact_form--required" aria-hidden="true">*</span></span>
</p>
<p class="contact_form__text_input">
<label for="name">Betreff <span class="contact_form--required" aria-hidden="true">*</span></label>
<input id="name" class="contact_form__subject" name="subject" type="text" value="" size="30" maxlength="245" required />
</p>
<p class="contact_form__textarea">
<label for="message">Nachricht <span class="contact_form--required" aria-hidden="true">*</span></label>
<textarea id="message" class="contact_form__message" aria-label="message" aria-hidden="true" cols="65" rows="7" name="message" required></textarea>