Jump to content

pure php back button


freelance84

Recommended Posts

I have found a point in my site where the user may wish to go back a page. Using the back button in the browser works perfectly fine. However, for aesthetical reasons and for "obvious function" reasons i need to create a button on the page which goes back a step in the browsers history.

 

I know I can do this with Javascript, but I would rather get it done with php first.

 

Therefore is it possible to create a back button in PHP. The back button in question will go back one step in the browsers history to the same .php it is currently on but in a previous state.

 

I found this from google, http://www.webmasterworld.com/forum88/870.htm, but then found there was some js in the answers.

I cannot find any other posts similar to this in php freaks

Link to comment
https://forums.phpfreaks.com/topic/209226-pure-php-back-button/
Share on other sites

You can get the previous page visited using $_SERVER['HTTP_REFERER'] but this will only work once since clicking back a second time will actually take you forwards.  The only way to do this in pure PHP would be to store a list of pages visited in the session and then work back along the list every time the back button is pressed.

 

Why can't you use a Javascript version?  A Javascript button would properly work with the browser back function so you'd keep stuff like forms filled in, POST queries etc.

Yea i thought as much. Its the post and form data i need too.

 

However as it is only in one point in the site it might be best to create another form with some hidden fields.

 

I don't want to use js for this feature as i feel it is a key feature. Therefore if the user cannot or doesnot have javascript on then they won't be able to use it. From all the books i've learnt from... etc i really feel a user without js should be able to use all the key functions of the site.

 

That list in the SESSIONS thought is pretty neat though, hadn't thought of that, cheers!  :D

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.