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 displa开发者_运维知识库ys the results, like on aa.com, ebay, autotrader, etc.
Thanks!
When you submit your page move the $_POST variables into the $_SESSION array and then header redirect the user to the results page.
You should redirect to another page to using redirect() method of codeigniter. This will prevent the browser asking a confirmation on form submission.
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.
精彩评论