Thom
Thom

Reputation: 107

How to display results so back button does not ask to reload POST variables

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!

Upvotes: 0

Views: 979

Answers (3)

Stephen Curran
Stephen Curran

Reputation: 7433

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.

Upvotes: 0

Teej
Teej

Reputation: 12873

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

Upvotes: 1

Paul Norman
Paul Norman

Reputation: 1673

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

Upvotes: 1

Related Questions