How do I clean information in a form after submit so that it does not show this error after a page refresh?
See image (from chrome):
The dialog has the text:
The page that you're looking for used
information that you entered. Returning to that
page might cause any action you took to be
repeated. Do you want to continue?
I want this dialog not to appear.
You could try using AJAX calls with jQuery. Like how youtube adds your comment without refreshing. This would remove the problem with refreshing overal.
You'd need to send the info necessary trough the ajax call.
I'll use the youtube comment as example.
You can now create the file
comment-on-video.php
and create something like this:I had a situation where I could not use any of the above answers. My case involved working with search page where users would get "confirm form resubmission" if the clicked back after navigating to any of the search results. I wrote the following javascript which worked around the issue. It isn't a great fix as it is a bit blinky, and it doesn't work on IE8 or earlier. Still, though this might be useful or interesting for someone dealing with this issue.
It seems you are looking for the
Post/Redirect/Get
pattern.As another solution you may stop to use redirecting at all.
You may process and render the processing result at once with no
POST
confirmation alert. You should just manipulate the browser history object:See full or short answers
It has nothing to do with your form or the values in it. It gets fired by the browser to prevent the user from repeating the same request with the cached data. If you really need to enable the refreshing of the result page, you should redirect the user, either via PHP (
header('Location:result.php');
) or other server-side language you're using. Meta tag solution should work also to disable the resending on refresh.After processing the POST page, redirect the user to the same page.
On
http://test.com/test.php
This will get rid of the box, as refreshing the page will not resubmit the data.
I had the same problem,
this worked for me,