Omzy Posted July 5, 2009 Share Posted July 5, 2009 I've currently got a "Back to Previous Page" Link using $_SERVER['HTTP_REFERER'] but I only want this link to be displayed if the user got to the page by browsing to it from the site, and not through a direct link from another site. Quote Link to comment https://forums.phpfreaks.com/topic/164843-back-to-previous-page-link/ Share on other sites More sharing options...
.josh Posted July 5, 2009 Share Posted July 5, 2009 if (stripos($url,'yourdomain.com')) echo $url; Quote Link to comment https://forums.phpfreaks.com/topic/164843-back-to-previous-page-link/#findComment-869215 Share on other sites More sharing options...
Omzy Posted July 5, 2009 Author Share Posted July 5, 2009 Can we not get it to check whether the referer was on the website's server or not? Quote Link to comment https://forums.phpfreaks.com/topic/164843-back-to-previous-page-link/#findComment-869240 Share on other sites More sharing options...
nbarone Posted July 5, 2009 Share Posted July 5, 2009 Can we not get it to check whether the referer was on the website's server or not? it does $url = $_SERVER['HTTP_REFERER']; Quote Link to comment https://forums.phpfreaks.com/topic/164843-back-to-previous-page-link/#findComment-869241 Share on other sites More sharing options...
Omzy Posted July 5, 2009 Author Share Posted July 5, 2009 Well ideally I need a universal solution, i.e. one where I don't have to explicitly specify the domain name. So it needs to basically check whether the referring page was a page on the server that the site is on. Quote Link to comment https://forums.phpfreaks.com/topic/164843-back-to-previous-page-link/#findComment-869245 Share on other sites More sharing options...
nbarone Posted July 5, 2009 Share Posted July 5, 2009 <?php $exp = explode(".",$_SERVER['HTTP_HOST'],3); if($exp[2]){ $mydomain = $exp[1]; } else { $mydomain = $exp[0]; } $url = $_SERVER['HTTP_REFERER']; if (strpos($url,$mydomain )) echo $url; ?> Quote Link to comment https://forums.phpfreaks.com/topic/164843-back-to-previous-page-link/#findComment-869246 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.