Determining if a user got to the page from an inside link

Discussion in 'PHP' started by Lindsey2002, Sep 20, 2007.

  1. #1
    Hi,

    I'm wondering if there is a php function or another way to determine if a user has got to a specific page using a internal link on the website and then showing a specific content or if he arrived from outside the server to show a different content or redirect him to another page.

    Thanks
     
    Lindsey2002, Sep 20, 2007 IP
  2. luiscardozo

    luiscardozo Peon

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can use the HTTP_REFERER predefined variable.

    From http://www.php.net/manual/en/reserved.variables.php:
    For example:
    Supose that this code is located here: http://www.digitalpoint.com/test.php
    
    <?php
    echo $_SERVER['HTTP_REFERER'];
    ?>
    PHP:
    If you clicked a link pointing to http://www.digitalpoint.com/test.php from http://www.youtsite.com/links.php then the HTTP_REFERER value would be "http://www.yoursite.com/links.php".

    Here, you will know from what site the user come from.

    Best regards
     
    luiscardozo, Sep 20, 2007 IP
  3. Lindsey2002

    Lindsey2002 Peon

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thanks a million!
     
    Lindsey2002, Sep 20, 2007 IP