So, I've a website that, once you're logged-in, uses a form to let you post a thing. (I'm using PHP/MySQL under the hood, but it's not that important here).
The trouble is that when they post the thing, sometimes they double-click the "post a thing" button. That posts two things.
Sometimes the form takes a short about of time to process, so they click the "post a thing" button again. That posts three things.
What's the best way to stop multiple form entries?
I've thought about...
- Hiding the button with JavaScript as soon as they click it, so that they can't double-click it, but that's not been very successful
- Checking that the title of the thing that they've just posted isn't the same as the title of a thing already in the database - but that'll give them an error even though the thing has successfully been posted and I don't want that
- Checking that they're not posting more than one thing in the last 60 seconds, but again, that'll give them an error even though it's been successfully posted
- Instead of giving them an error in #2 or #3, take them somehow to the successful initial page thing
Am I overlooking a really simple method of avoiding a form being submitted twice? Is there something in HTML these days to stop this from happening?