I have a simple form that submits text to my SQL table. The problem is that after the user submits the text, they can refresh the page and the data gets submitted again with
I found next workaround. You may escape the redirection after processing POST
request by manipulating history object.
So you have the HTML form:
When you process this form on your server you instead of redirecting user to /the/result/page
by setting up the Location
header like this:
$cat process.php
After processing POST
ed data you render small and the result
/the/result/page
// see below
render `/the/result/page` // OK
?>
The you should render:
The result is:
as you can see the form data is POST
ed to process.php
script.
This script process POST
ed data and rendering /the/result/page
at once with:
POST
data when you refresh page (F5) POST
when you navigate to previous/next page through the browser historyUPD
As another solution I ask feature request the Mozilla FireFox team to allow users to setup NextPage
header which will work like Location
header and make post/redirect/get
pattern obsolete.
In short. When server process form POST
data successfully it:
NextPage
header instead of Location
POST
form data as it would render for GET
request in post/redirect/get
patternThe browser in turn when see the NextPage
header:
window.location
with NextPage
valueGET
request to NextPage
instead of rePOST
form dataI think this would be excelent if implemented, would not? =)