If the user reloads the page or comes back to the page, the data will be sent again.
If I don’t send the user after the successful send to another page - what can I do to prevent the data from being sent again? How to unset $data after send.
controller - Works without resending
// no exception occurred, let's send a success message
if (empty($alert) === true) {
go(some page');
}
controller - resends data
// no exception occurred, let's send a success message
if (empty($alert) === true) {
$success = 'Your message has been sent, thank you. We will get back to you soon!';
$data = [];
}
hi there.
iam currently implementing a contact form as well with the help of your cookbook example.
the mentioned pattern would not work in that example right?. because it would not return any data. is this correct? but where to implement the pattern and how should the controller look like then? can you point my in the right direction since its a long time ago i did such things in php and not in the frontend via js? (want to stick with php and “regular” post in this case).
thanx in advanced.
setting the disabled prop on the submit button after the submit event fired can also prevent duplicate submissions. but be wary you might need a way to unlock it again if the form does not validate.