Jump to content

Determine if user came from inner link or an outside link


yoda69

Recommended Posts

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.

Link to comment
Share on other sites

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
    }
    }

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.