Return to post-query page
Moderator: General Moderators
Return to post-query page
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
a multitude of ways.
(never personally used, but give it a go)
or you could store the result in a session/cookie.
Code: Select all
<a href="javascrpt:void(0)" onclick="history.go(-1)">go back</a>or you could store the result in a session/cookie.
Re: Return to post-query page
I'll try the javascript method, and thanks. Panic
Re: Return to post-query page
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
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
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.
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,'/');
}
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
Thanks I will try it. I appeciate it.
Re: Return to post-query page
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.