0

I have a form that uses XML to get results. From those results users can click to a detail page. My problem is when a user clicks back to the results page, they are asked if they want to submit the form again. How do I create this so back button just displays the results, like on aa.com, ebay, autotrader, etc.

Thanks!

Teej
  • 12,764
  • 9
  • 72
  • 93
Thom
  • 107
  • 3
  • 9
  • Dupe: http://stackoverflow.com/questions/660329/prevent-back-button-from-showing-post-confirmation-alert – gnarf Dec 09 '10 at 17:37
  • 3
    The actual solution: The ["Post/Redirect/Get Pattern"](http://en.wikipedia.org/wiki/Post/Redirect/Get) - If you `header('Location: /someotherpage.php");` in response to the post - it will not ask the user to resubmit post data. – gnarf Dec 09 '10 at 17:39

3 Answers3

1

When you submit your page move the $_POST variables into the $_SESSION array and then header redirect the user to the results page.

Paul Norman
  • 1,621
  • 1
  • 9
  • 20
1

You should redirect to another page to using redirect() method of codeigniter. This will prevent the browser asking a confirmation on form submission.

Teej
  • 12,764
  • 9
  • 72
  • 93
0

Is it just a search page that displays results? Why not use GET rather than POST in your form? Looking at search engines out there, they seem to use GET for their search interface. I can think of a few reasons to use GET rather than POST.

  • If the operation simply fetches results, semantically, the GET method is more appropriate. GET is used when you are fetching data. POST is more used when you are submitting a change to the application.
  • If you use GET, clicking on the back button won't give you a dialog asking whether you wish to resubmit the form.
  • Your users will have a URL directly to a search results page for a particular query that they can share.

Unfortunately CodeIgniter, by default, nukes the query string when processing a request. You can enable the query string in CodeIgniter by following this answer.

Community
  • 1
  • 1
Stephen Curran
  • 7,433
  • 2
  • 31
  • 22