Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Dec 2005
    Posts
    217
    Thanks
    1
    Thanked 0 Times in 0 Posts

    $_SERVER['HTTP_REFERER'] not working on the server ??

    Hello forums!!
    Case:
    In localhost:
    PHP Code:
    $_SERVER['HTTP_REFERER'
    works fine but it shows error in the server as: " Undefined index: HTTP_REFERER". I dont know why its not working there.

    Whats the solution for this: any setting should be made to php.ini or else ?

    Thanks in advance for the help.

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    From the PHP manual:

    The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.

  • #3
    Regular Coder
    Join Date
    Apr 2008
    Location
    New Jersey
    Posts
    116
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Understanding that sometimes the value won't be there, you can avoid the warning with:

    PHP Code:
    $ref = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null
    Chaos
    Lost Souls: text based RPG | MUDseek: MUD gaming search | MUDfind: MUD resource sites | Discordian Quotes

  • #4
    New to the CF scene
    Join Date
    May 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by chaosprime View Post
    Understanding that sometimes the value won't be there, you can avoid the warning with:

    PHP Code:
    $ref = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null


    Thanks chaosprime. I know it's been a while since your post, but I thought that I would throw this up here for any future viewers to see. Here is a php script that I used for a login in form that can be accessed from either (address bar), (.htaccess redirect), (form redirect after registration), or (from any other link).

    PHP Code:
    <?php
    $ref 
    = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null;
    if(
    $ref == null){
      echo 
    "Your browser must allow cookies in order to log in.";
    } else {
      if (
    $_SERVER['HTTP_REFERER'] == "http://www.YourURL.com/login/register.php")){
        echo 
    "Thank you for registering! A confirmation email has been sent to your address.<br />Please click on the link in that email in order to activate your account.";
      } else {
        echo 
    "Your browser must allow cookies in order to log in.";
      }
    }
    ?>
    Last edited by compbugs; 05-20-2009 at 07:31 PM.

  • #5
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,638
    Thanks
    2
    Thanked 404 Times in 396 Posts
    Quote Originally Posted by compbugs View Post


    Thanks chaosprime. I know it's been a while since your post, but I thought that I would throw this up here for any future viewers to see. Here is a php script that I used for a login in form that can be accessed from either (address bar), (.htaccess redirect), (form redirect after registration), or (from any other link).

    PHP Code:
    <?php
    $ref 
    = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null;
    if(
    $ref == null){
      echo 
    "Your browser must allow cookies in order to log in.";
    } else {
      if (
    $_SERVER['HTTP_REFERER'] == "http://www.YourURL.com/login/register.php")){
        echo 
    "Thank you for registering! A confirmation email has been sent to your address.<br />Please click on the link in that email in order to activate your account.";
      } else {
        echo 
    "Your browser must allow cookies in order to log in.";
      }
    }
    ?>
    Err... the browser disallowing cookies has nothing to do with the referrer. You should really put that message saying the mail has been sent on the page that processes your registration. Hopefully it's not the one you posted, because that is poor logic.

  • #6
    Regular Coder kokjj87's Avatar
    Join Date
    Sep 2008
    Location
    Singapore
    Posts
    279
    Thanks
    1
    Thanked 55 Times in 54 Posts
    Inigoesdr is right, when there is no referrer, it can only be 2 things, first is the user access the page directly, second is some of the internet security program(like norton) blocks it..


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •