i have a site that lets people post and search events.
i've noticed that when a user spends a long time on a form either posting an event or choosing their search parameters that it's very easy to lose this information.
problem 1: accidentally click the forward or back buttons on your browser the form gets reset when you return to the page
i don't see that there is much that can be done - unless somehow the form is being evaluated by php every time you visit. Might there be some way to just cache the form...like send a Pragma or Cache-Control header that tells the browser and/or server to only re-evalute the php code under certain conditions? What might some conditions be?
Problem 2: if you take a good amount of time filling ou the elaborate search form and submit it you get the results, but when you click 'back' the form is reset rather than reflecting your latest search.
I am considering putting the user's search parameters in session when they click submit. if they click back after viewing the search results, the search page always looks in the session to see if there are any values there so you will see the last parameters you selected rather than a blank form.
this gets tricky though. for a couple of reasons:
my site uses GET for its forms so that users can email search results to each other (like google). i don't want a search that someone emails or IMs to you to automatically replace the search in your session
if the user opts to work with the search emailed or IMed from a friend, i do want it to take over the session - but only if they explicitly click a link or button
so i'm thinking of setting up my search form like this:
*** SEARCH FORM ***
if POST data {
if POST is valid store params in SESSION and redirect to results with params
in the query string (e.g., results.php?start_date=1/1/2001&foo=bar)
if POST is not valid, show the form using the POST data
} else if no POST data {
if SESSION has search params, show the form with those
else if GET has search params show the form with those
else - no params, show blank form
}
then my results page will
perform the search, always looking to the GET vars for the search params.
if there are not GET params, then ERROR
* show a link to adopt the current GET params as my SESSION search
Does that sound viable?