#105_kontaktformular #121

Merged
muli merged 21 commits from #105_kontaktformular into main 2022-08-23 21:58:46 +02:00
4 changed files with 9 additions and 1 deletions
Showing only changes of commit e53449352f - Show all commits

View File

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

View File

@ -1,6 +1,7 @@
const ajaxUrl = 'https://spielwiese.wtf-eg.de/php/contact_form.php'; const ajaxUrl = 'https://spielwiese.wtf-eg.de/php/contact_form.php';
// const submit_button = document.getElementsByClassName('contact_form__submit_button')[0]; // const submit_button = document.getElementsByClassName('contact_form__submit_button')[0];
const contact_form = document.getElementsByClassName('content__contact_form')[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 message = document.getElementsByClassName('contact_form__message')[0];
const name = document.getElementsByClassName('contact_form__name')[0]; const name = document.getElementsByClassName('contact_form__name')[0];
const email = document.getElementsByClassName('contact_form__email')[0]; const email = document.getElementsByClassName('contact_form__email')[0];
@ -26,6 +27,7 @@ contact_form.addEventListener('submit', function(event) {
event.preventDefault(); event.preventDefault();
let formData = new FormData(); let formData = new FormData();
formData.append('action', 'handle_form'); formData.append('action', 'handle_form');
formData.append('subject', subject.value);
formData.append('message', message.value); formData.append('message', message.value);
formData.append('name', name.value); formData.append('name', name.value);
formData.append('email', email.value); formData.append('email', email.value);

View File

@ -63,11 +63,12 @@ function prepare_response() {
$response['errors'][] = 'Wir glauben du bist ein Bot.'; $response['errors'][] = 'Wir glauben du bist ein Bot.';
} }
if (!array_key_exists('errors', $response)) { if (!array_key_exists('errors', $response)) {
$subject = sanitize_text('subject');
$message = sanitize_text('message'); $message = sanitize_text('message');
$name = sanitize_text('name'); $name = sanitize_text('name');
$email = sanitize_text('email'); $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.'; $response['errors'][] = 'Deine Nachricht konnte nicht übermittelt werden.';
} else { } else {
$response['status'] = 'ok'; $response['status'] = 'ok';

View File

@ -25,6 +25,10 @@
Deine E-Mail-Adresse wird nicht veröffentlicht.<br> 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> <span aria-hidden="true">Erforderliche Felder sind gekennzeichnet <span class="contact_form--required" aria-hidden="true">*</span></span>
</p> </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"> <p class="contact_form__textarea">
<label for="message">Nachricht <span class="contact_form--required" aria-hidden="true">*</span></label> <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> <textarea id="message" class="contact_form__message" aria-label="message" aria-hidden="true" cols="65" rows="7" name="message" required></textarea>