I'm creating a search feature with pagination.
I have a form and I get it's POST value. I then use this to search the database and return a set of results.
The results are broken up in to pages and a user can click page links in the view.
My question is, how can I persist the search over multiple pages?
Should the first page get the POST value and on subsequent pages should I put the search term into the url, eg.
www.example.com/search/various-keywords/p2
Then get the term and query the database again, splitting the results to whatever page it is, p2, p3, p4 etc.
Is there a cleaner way to do this?
Also, is it unsafe to include the users input in the url? Should I encode it in some way?
And if the user was to click back after going through a number of pages I would get the 'Confirm Form Resubmission' error. How can I prevent this?