Mobile app version of vmapp.org
Login or Join
Candy875

: Prevent form resubmit after Browser Back button click In the early days of the web it was a problem that clicking the browser's Back button after clicking Submit could cause the form to be

@Candy875

Posted in: #Browsers #Forms

In the early days of the web it was a problem that clicking the browser's Back button after clicking Submit could cause the form to be resubmitted so one might, for instance, end up with a double purchase.

This does not seem to be a problem any longer. How was it fixed? Do individual sites have to work around this or did browsers change?

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Candy875

2 Comments

Sorted by latest first Latest Oldest Best

 

@Shanna517

One way to prevent this is to use the POST/Redirect/GET pattern.

Instead of directly sending a 200 after receiving the POST request, the server sends a 303 (or 302) redirect instead. The client follows it and gets (via GET) a 200 then. Refreshing this page repeats the last GET, not the previous POST.

For implementation questions, see the Stack Overflow tag "post-redirect-get".

10% popularity Vote Up Vote Down


 

@Cody1181609

I've used a javascript POST of the form data followed by a js re-direct. Using the back button doesn't cause those forums to be re-submitted.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme