How To Check the referrer of the site

Discussion in 'PHP' started by niitdebasis, Jan 10, 2009.

  1. #1
    Hello Friends I need your help i have a php site and i need a php code from which i can able to know from where visitors coming to my site and from which IP address etc....there are many plugins available from which we can easily know about the visitors but i want the manual php code from which we can easily know about this.Please provide me the code and also advice me how to use it in my site the procedure to use the code in my site.
    Waiting for your reply.Its Urgent for me to know this.
    Thanks.
     
    niitdebasis, Jan 10, 2009 IP
  2. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #2
    $referrer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
    $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '0.0.0.0';
    PHP:
    Could use any other default IP, if they aren't providing an IP, they shouldn't be allowed to access your server anywhere (default die() on my servers.)

    Dan
     
    Danltn, Jan 10, 2009 IP
  3. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #3
    Like dan said,

    $_SERVER['HTTP_REFERER'] carries the website where the user come from.
    If its empty, visitors might be directly entering your website url or blocked by software.

    $_SERVER['REMOTE_ADDR'] carries the ip address of the visitor.
     
    ads2help, Jan 10, 2009 IP
  4. niitdebasis

    niitdebasis Banned

    Messages:
    84
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks For The Reply.
     
    niitdebasis, Jan 10, 2009 IP