Tee tarjouspyyntölomake toimivaksi (PHP-backend + sähköposti)
Lisätty api.php:hen quote-action joka validoi, tallentaa data/quotes.json-tiedostoon ja lähettää sähköpostin osoitteeseen support@konesaliturku.fi. Sisältää honeypot- bottitorjunnan ja rate limitingin. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -410,16 +410,36 @@
|
||||
const honeypot = form.querySelector('[name="website"]');
|
||||
if (honeypot && honeypot.value) return;
|
||||
|
||||
const submitBtn = form.querySelector('.btn-submit');
|
||||
submitBtn.disabled = true;
|
||||
status.textContent = 'Lähetetään...';
|
||||
status.className = 'form-status';
|
||||
|
||||
// Simulate send
|
||||
setTimeout(function() {
|
||||
status.textContent = 'Kiitos! Tarjouspyyntösi on vastaanotettu. Otamme yhteyttä vuorokauden sisällä.';
|
||||
status.className = 'form-status form-status-success';
|
||||
form.reset();
|
||||
calculate();
|
||||
}, 1000);
|
||||
const formData = new FormData(form);
|
||||
|
||||
fetch('api.php?action=quote', {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
})
|
||||
.then(function(res) { return res.json(); })
|
||||
.then(function(data) {
|
||||
if (data.error) {
|
||||
status.textContent = data.error;
|
||||
status.className = 'form-status form-status-error';
|
||||
} else {
|
||||
status.textContent = 'Kiitos! Tarjouspyyntösi on vastaanotettu. Otamme yhteyttä vuorokauden sisällä.';
|
||||
status.className = 'form-status form-status-success';
|
||||
form.reset();
|
||||
calculate();
|
||||
}
|
||||
})
|
||||
.catch(function() {
|
||||
status.textContent = 'Virhe lähetyksessä. Yritä uudelleen tai ota yhteyttä sähköpostilla.';
|
||||
status.className = 'form-status form-status-error';
|
||||
})
|
||||
.finally(function() {
|
||||
submitBtn.disabled = false;
|
||||
});
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user