refiking Posted June 30, 2008 Share Posted June 30, 2008 Is there a way to retrieve where a link was clicked in php without rewriting each page the link is located on? For example, I have a contact us page. Is there in php to call the address of the page they clicked to get to the contact us page? Thanks in advance! Link to comment https://forums.phpfreaks.com/topic/112532-how-to-retrieve-the-reffered-address/ Share on other sites More sharing options...
thatsgreat2345 Posted June 30, 2008 Share Posted June 30, 2008 So you want something that will change the current page being displayed with out reloading the page? If so this would require ajax which is javascript. Link to comment https://forums.phpfreaks.com/topic/112532-how-to-retrieve-the-reffered-address/#findComment-577817 Share on other sites More sharing options...
aeonsky Posted June 30, 2008 Share Posted June 30, 2008 Yes... $referrer = getenv(HTTP_REFERER); or $referrer = $_SERVER['HTTP_REFERER']; Link to comment https://forums.phpfreaks.com/topic/112532-how-to-retrieve-the-reffered-address/#findComment-577822 Share on other sites More sharing options...
refiking Posted June 30, 2008 Author Share Posted June 30, 2008 OK. Now, how do I take off the http://domain.com section of the address? I just want the actual page's name so I can store in DB. Thanks again! Link to comment https://forums.phpfreaks.com/topic/112532-how-to-retrieve-the-reffered-address/#findComment-577825 Share on other sites More sharing options...
aeonsky Posted June 30, 2008 Share Posted June 30, 2008 Use ltrim. ltrim($referrer, "http://domain.com/"); But if you just need the end part, there is a value for that! $referrer_without_beginning = $_SERVER['REQUEST_URI']; Link to comment https://forums.phpfreaks.com/topic/112532-how-to-retrieve-the-reffered-address/#findComment-577826 Share on other sites More sharing options...
refiking Posted June 30, 2008 Author Share Posted June 30, 2008 $_SERVER['REQUEST_URI'] didn't work. And when I used ltrim, it deleted the first letter of the page. So, contactus.php returned ontactus.php Link to comment https://forums.phpfreaks.com/topic/112532-how-to-retrieve-the-reffered-address/#findComment-577829 Share on other sites More sharing options...
aeonsky Posted June 30, 2008 Share Posted June 30, 2008 Something wrong with serv, mine working perfectly. Link to comment https://forums.phpfreaks.com/topic/112532-how-to-retrieve-the-reffered-address/#findComment-577833 Share on other sites More sharing options...
refiking Posted June 30, 2008 Author Share Posted June 30, 2008 Could it be that I have a variable at the end? All my pages have ?cid=xxx depending on the city. Does that matter? ??? Link to comment https://forums.phpfreaks.com/topic/112532-how-to-retrieve-the-reffered-address/#findComment-577837 Share on other sites More sharing options...
refiking Posted June 30, 2008 Author Share Posted June 30, 2008 It helps to add the semicolon. LOL. I need coffee or sleep. Link to comment https://forums.phpfreaks.com/topic/112532-how-to-retrieve-the-reffered-address/#findComment-577838 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.