I've recently taken to doing a header() redirect (to the same page) after certain forms on my website have been submitted (mostly related to a shopping cart application) so that the user doesn't do unintended things by refreshing the page or by going "back" or "forward" and refreshing the page. Is this an acceptable practice?
This is standard practice called redirect after post or Post/Redirect/Get. It's considered best practice when dealing with post forms
Yes, it is a good practice. It makes things much friendlier to the user. It's also probably the second-best solution, in fact (the first, of course, being to use Ajax primarily)! Just make sure to only do it on success.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With