$_SERVER['HTTP_REFERER']; why doesn't it work??

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Muffinman

    $_SERVER['HTTP_REFERER']; why doesn't it work??

    Hi,

    I have a script using the $_SERVER['HTTP_REFERER'] var. I now installed
    php 5 and this function does not work, 'undefined index' it says. Can
    anyone tell me what could be wrong?

    Thanks in advance, Maarten

    ps. this is not the same server as to which I refered in my other post.

  • Chris Hope

    #2
    Re: $_SERVER['HTTP_REFERER']; why doesn't it work??

    Muffinman wrote:
    [color=blue]
    > I have a script using the $_SERVER['HTTP_REFERER'] var. I now
    > installed php 5 and this function does not work, 'undefined index' it
    > says. Can anyone tell me what could be wrong?[/color]

    It won't be set if no referer information was passed by the browser.

    There are three circumstances I can think of when the referer
    information is not passed to the browser:

    1) The user has typed the address into their browser, clicked a link in
    an email client, used a bookmark etc. The referer info will not be set
    as they have not been refered from another web page.

    2) The user has a browser preference which prevents the referer
    information from being passed or uses proxy type software which
    prevents this from being passed. (Sometimes this software passes a
    referer url but if it does it's usually either the same as the
    requested page or the site's homepage and will be the same as they move
    from page to page).

    3) It's a robot/spider or some script created by the user. These
    typically won't pass referer information as they move from page to
    page. (Some exceptions are spammy type bots which post a referer url
    back to their own site).

    --
    Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/

    Comment

    • Tony Reed

      #3
      Re: $_SERVER['HTTP_REFERER']; why doesn't it work??

      On Sun, 19 Dec 2004 17:26:41 +1300
      Chris Hope <blackhole@elec trictoolbox.com > wrote:

      :Muffinman wrote:
      :
      :> I have a script using the $_SERVER['HTTP_REFERER'] var. I now
      :> installed php 5 and this function does not work, 'undefined index' it
      :> says. Can anyone tell me what could be wrong?
      :
      :It won't be set if no referer information was passed by the browser.

      .... and it's not an "error," it's a "notice." The OP can either lower
      his error-reporting level:

      error_reporting (E_ALL ^ E_NOTICE);

      or use isset() to check HTTP_REFERRER before trying to use it.

      --
      Tony Reed
      <trljc@altern.o rg>

      Comment

      • Michael Fesser

        #4
        Re: $_SERVER['HTTP_REFERER']; why doesn't it work??

        .oO(Tony Reed)
        [color=blue]
        >... and it's not an "error," it's a "notice." The OP can either lower
        >his error-reporting level:
        >
        >error_reportin g(E_ALL ^ E_NOTICE);[/color]

        Ignoring notices is bad style and may lead to errors that are hard to
        find.
        [color=blue]
        >or use isset() to check HTTP_REFERRER before trying to use it.[/color]

        That's how it should be.

        Micha

        Comment

        Working...