Back button re-submit form data ($_POST)

If you are submitting a form with search parameters, you are trying to get some data, not modify some.

So, you should use the HTTP GET method, and not POST : POST should be used when you intend to create/modify data, and GET should be used when you intend to fetch some data.

Or, if you have some create/modify operation that has to be done :

  • The form first POSTs to a first page
    • That page does some operations (like writing something to a database)
    • And then redirects to another page, using a Location HTTP header.
  • It’s that last page, that’s queries by the browser using a GET requests, that displays the data fetched from the parameters received in the URL.

See the Post/Redirect/Get page on wikipedia, about this.

Leave a Comment