Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it a good practice to redirect after a form has been submitted?

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?

like image 879
Nate Avatar asked Dec 07 '25 07:12

Nate


2 Answers

This is standard practice called redirect after post or Post/Redirect/Get. It's considered best practice when dealing with post forms

like image 144
Maxim Krizhanovsky Avatar answered Dec 08 '25 20:12

Maxim Krizhanovsky


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.

like image 41
Ry- Avatar answered Dec 08 '25 20:12

Ry-



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!