Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do we need redirect after sending post request?

Tags:

forms

php

symfony

There are 3 forms for update data on the page: 1st is for user profile, 2nd - for password reset, 3rd - for changing e-mail. I made sending forms to controller and redirect to the same page. Project team leader asked to remove those redirects and said that people don't refresh the page after submitting the form and redirects will only load the server... I could be wrong but redirects are always supposed to be done after sending POST request. My suggestion about making all forms via AJAX was declined. How can I prove competently that there is a need for redirect if I'm not mistaken?

like image 963
K. Igor Avatar asked Feb 07 '23 14:02

K. Igor


1 Answers

The point you are looking for is the Post-Redirect-Get pattern.
You can read the original article here: http://www.theserverside.com/news/1365146/Redirect-After-Post

It exposes all the motives ; in short, the pattern prevent double-submit (because the page is slow, so the user loose patience) and allows the browser to safely refresh the (last) page, without risking to re-submit data (or at least having that pop-up warning you you are re-submitting data).

like image 68
romaricdrigon Avatar answered Feb 12 '23 02:02

romaricdrigon