yoda69 Posted September 21, 2007 Share Posted September 21, 2007 Hey guys, any php method or function to determine if a user came from within the website or from an outside website. I have a page that I want to display in different manners depends on how did the user arrive at my site. I know about the HTTP_REFERER function. but don't really know how to use it. I know this is the syntax: <?php echo $_SERVER['HTTP_REFERER']; ?> but when i entered the code in the php page. for instance test.php, there is nothing coming up. So my questions: 1. is there any other method? 2. could any of you maybe specify a bit more details about this function and how to use it. thanks a million. Quote Link to comment https://forums.phpfreaks.com/topic/70179-determine-if-user-came-from-inner-link-or-an-outside-link/ Share on other sites More sharing options...
rarebit Posted September 21, 2007 Share Posted September 21, 2007 http://uk3.php.net/manual/en/reserved.variables.php Value is set by user, so it can't always be trusted... Quote Link to comment https://forums.phpfreaks.com/topic/70179-determine-if-user-came-from-inner-link-or-an-outside-link/#findComment-352505 Share on other sites More sharing options...
AdRock Posted September 21, 2007 Share Posted September 21, 2007 This is how I check if the user came from my website // Stop the form being used from an external URL // Get the referring URL $referer = $_SERVER['HTTP_REFERER']; // Get the URL of this page $this_url = "http://".$_SERVER['HTTP_HOST'].$_SERVER["REQUEST_URI"]; // If the referring URL and the URL of this page don't match then // display a message and don't send the email. if ($referer != $this_url) { echo "You do not have permission to use this script from another URL.<br />"; echo "If you are behind a firewall please check your referrer settings."; exit; else { //do something else } } Quote Link to comment https://forums.phpfreaks.com/topic/70179-determine-if-user-came-from-inner-link-or-an-outside-link/#findComment-352547 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.