How do I stop duplicating the database

How do i stop this???

I think its not a infinityfree bug but is a mu sql When you refresh it a million times its duplicating

Heres the link: https://www.them.ga/tests/t2

Because you send the request to the webpage successfully and it executes very quickly but it takes a bit longer to redirect you to that page again, that’s why you can duplicate it with pressing the submit button multiple times (or refreshing the page):

Because the browser keeps $_POST data in itself until you leave that page, and since your php code is being executed when $_POST is set, then it’ll still submit data with refreshing.
to prevent this you’ve to unset it in end of your code.

  1. To prevent spam submitting through the submit button you have to disable it after it is clicked:
<script>
const button = document.querySelector('input[type=text]');
button.addEventListener("click",()=>{
   button.disabled=true;
});
</script>
  1. To prevent submitting data via refreshing the page, you have to unset the POST data after executing the form, add this at end of your php statement:
unset($_POST);
4 Likes

There isn’t really a way to stop it. POST content is only supposed to be set once, and most browsers warn you when you try to refresh a POST request.

If you really want to prevent people from spamming the form, some kind of CSRF system (where the token gets rotated after each POST submission) or a CAPTCHA could help.

3 Likes

Ok thanks

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.