Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Going back without refreshing page problem 1

Status
Not open for further replies.

meeble3

Programmer
Nov 8, 2004
52
GB
Hello,

I have a page with a search on it. When you go to it then go to the next page, if you press back, it tells you that you need to refresh the page to get the data again.

How do you prevent this?

Cheers

James
 
This has to do with the "no-cache" pragma, a header sent to that effect or something similar.
If the page is created by PHP and sessions are active look at the cache settings.
 
The page is created by using PHP but I am not using sessions...
 
You will also receive this message if you are using 'post' as the method to a form. I have been advised to use the 'get' method instead. I changed my forms to get and it did stop, but as for any more insight as to why I could not tell you.
 
meeble3:
Why do you need this?
Cant you simply link back to the search-form, with a variable in the querystring?

Or, maybe use sessions to store the searchstring?

eg.:
<a href="search.php?q=<?=$searchstring?>" title="Go back to the search-form">Go back</a>

or, maybe store in sessions, that is easier..
just remember: You need to start the session at the very top of every page where you want the session to be passed.

If the session has non-vital data, you can also include the SID in the hyperlinks, as well as the form actions, as then it will be passed also if the client does not accept the session cookie. (firewall or some other reason).

How to pass the SID:
<a href="search.php?<?=SID?>" title="Go back to searchform">Go back</a>

I guess you get the general idea..

Good luck :)

Olav Alexander Mjelde
Admin & Webmaster
 
But what about clicking the 'back button' on your browser?
 
Browsers are a pain. Most of them behave differently, even the interpretation of what is being considered cache etc.
For example, Opera takes the HTTP definition literally and only reloads a page when it is accessed via a link. The back button will always (even with meta tags, headers etc.) be fetched from the disk cache.

From the prospective of interface design you should just make your page containing the search form itself on the top/bottom of the page. That way there is absolutely no need to go back.
Look at the behavior of search engine pages, Google etc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top