Page 1 of 1

Return to post-query page

Posted: Sat Sep 06, 2008 9:17 am
by phillyrob
I have a setup where you can query for data and get a result. It works fine. You can then click on a link in the result to go to another page. I then want the user to be able click a link and return to the previous page (the results page) post query and not have to search again. Can someone explain how that can be done? return to the p

Re: Return to post-query page

Posted: Sat Sep 06, 2008 10:20 am
by panic!
a multitude of ways.

Code: Select all

<a href="javascrpt:void(0)" onclick="history.go(-1)">go back</a>
(never personally used, but give it a go)

or you could store the result in a session/cookie.

Re: Return to post-query page

Posted: Sat Sep 06, 2008 10:23 am
by phillyrob
I'll try the javascript method, and thanks. Panic

Re: Return to post-query page

Posted: Sat Sep 06, 2008 10:34 am
by phillyrob
Sorry Panic I tried the Javascript, but not familiar with it. I put it in verbatim (probably shouldn't have of course).Can you elaborate? Where do I pluge in the page that I want it to return to.

Re: Return to post-query page

Posted: Sat Sep 06, 2008 10:49 am
by panic!
put this link on the page after the results page, then they can click it and go back to the results, they will however be warned that they will be POST-ing data again.


I think a better way would be something like this

Code: Select all

 
 
if(!$_POST['query'] && $_COOKIE['query'])
{
$_POST['query']=$_COOKIE['query'];
}
else
{
setcookie('query',$_POST['query'],time()+3600,'/');
}
 
what this does it, looks for the query in the POST data, if it's not there, look in the cookie 'query' if it can find this set the POST data for query to the cookie.

If it finds the POST data straight away, it sets the cookie for a future time if there is no POST data for query.

Obviously change the variable $_POST['query'] to the name of your input field.

Re: Return to post-query page

Posted: Sat Sep 06, 2008 10:50 am
by phillyrob
Thanks I will try it. I appeciate it.

Re: Return to post-query page

Posted: Sat Sep 06, 2008 11:46 am
by phillyrob
I am using the javascript and got it to work, only thing is it won't work in ie, works fine in firefoex. Have you seen that? Is there a work around.