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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pages only viewed once?

Status
Not open for further replies.

youradds

Programmer
Jun 27, 2001
817
GB
Hi. I would like to try and make a PHP page only show once. Is there a way I can return an error message if they try and click 'back' or 'refresh'??

Thanks

Andy
 
Nope, back is cached in the browser.
There are two ways, prevent it with javascript, or:
put in the page u dont want to be cached <meta http-equiv=&quot;pragma&quot; content=&quot;no-cache&quot;> en the rest, must revalidate etc.
In this way the page must be loaded from the server.
the in that page check the referrer, if it is the last page mentioned, put the error message on the screen and die.

For exact meta statements you have to consult another resource, dont have any at hand.

Good luck mcvdmvs
&quot;It never hurts to help&quot; -- Eek the Cat
 
use sessions.

check for a session variable when the page is loaded.. if it shows that the user has been there, echo a &quot;you cant do that&quot;, otherwise, set the session var and display the page as planned. when the user tries to come back to the page (assuming you use all the no-cache headers you can), it'll detect the session var and give them a &quot;you cant do that&quot; error.

this is the best way to do it, short of storing each of the user's actions... this gets messy though. sessions are so easy! -gerrygerry
Go To
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top