freelance84 Posted July 29, 2010 Share Posted July 29, 2010 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 Quote Link to comment Share on other sites More sharing options...
Cagecrawler Posted July 29, 2010 Share Posted July 29, 2010 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. Quote Link to comment Share on other sites More sharing options...
freelance84 Posted July 29, 2010 Author Share Posted July 29, 2010 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! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.