I am designing a huge site where we will allow people to post products for sale. I need to have a link at the bottom of each page that will take you to the previous page. So, in PHP I am just creating a link to $_SERVER["HTTP_REFERRER"]
However, the problem is, the referring pages have variables on the end of the url that the http_referrer variable does not grab. These variables are critical to distinguishing different pages. An example url is
http://garagesaleslocal.com/view.php?ac ... type=admin
My question is this
How can I get the $_GET variable that are at the end of the URL and add them to my go back link???
Help with a link to referring page
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
as I've said, you can use the session as a means to transfer it over from page to page:
now, there are some precautions needed, like nowing when and when not to actually run this kind of code. For instance, say you travel to an "add to cart" type page, and the user wants to add more than one to their cart. This page shouldn't store a last_page in the session, or it will lose the ability to "continue shopping"
Code: Select all
session_start();
$_SESSIONї'last_page'] = $_SERVERї'SCRIPT_NAME'] . (!empty($_SERVERї'QUERY_STRING']) ? '?' . $_SERVERї'QUERY_STRING'] : '');-
magicrobotmonkey
- Forum Regular
- Posts: 888
- Joined: Sun Mar 21, 2004 1:09 pm
- Location: Cambridge, MA
alternativly you can do it in javascript - as long as you handle the cache correctly, it should work:
Code: Select all
<a href="javascript:history.go(-1)">
Go Back
</a>