Formular-Handling verbessert: CSRF-Token hinzugefügt, AJAX-Formularübermittlung implementiert und neue CSS-Stile für verschiedene Abschnitte hinzugefügt.

This commit is contained in:
Samuel Müller
2025-07-31 15:47:00 +02:00
parent 3df2a0efea
commit 0e49848a78
8 changed files with 944 additions and 15 deletions

View File

@@ -66,21 +66,36 @@
submitBtn.textContent = 'Wird gesendet...';
submitBtn.disabled = true;
// Simulate form submission (replace with actual endpoint)
setTimeout(() => {
// Reset form
form.reset();
// Show success message
showNotification('Ihre Nachricht wurde erfolgreich gesendet! Wir melden uns in Kürze bei Ihnen.', 'success');
// Send form data to PHP backend
fetch('contact-handler.php', {
method: 'POST',
body: formData
})
.then(response => response.json())
.then(data => {
if (data.success) {
// Reset form
form.reset();
// Show success message
showNotification(data.message, 'success');
// Scroll to top
window.scrollTo({ top: 0, behavior: 'smooth' });
} else {
// Show error message
showNotification(data.message, 'error');
}
})
.catch(error => {
console.error('Error:', error);
showNotification('Es gab ein Problem beim Senden Ihrer Nachricht. Bitte versuchen Sie es später erneut.', 'error');
})
.finally(() => {
// Reset button
submitBtn.textContent = originalText;
submitBtn.disabled = false;
// Scroll to top
window.scrollTo({ top: 0, behavior: 'smooth' });
}, 2000);
});
});
}