Question about $HTTP_HOST, $HTTP_REFERER

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ssk@chol.net

    Question about $HTTP_HOST, $HTTP_REFERER

    Hello!

    I made a web site using PHP Open sources for message board.
    Everything's fine except one computer can't open a message writing
    page.

    The code that gives an error is the following.

    if(!eregi($HTTP _HOST,$HTTP_REF ERER)) Error("Write in the normal way");

    The browser is IE 6.0 and I configured the options the same as other
    computer.

    What's wrong?

    TIA.
    Sam

  • Chris Hope

    #2
    Re: Question about $HTTP_HOST, $HTTP_REFERER

    ssk@chol.net wrote:
    [color=blue]
    > I made a web site using PHP Open sources for message board.
    > Everything's fine except one computer can't open a message writing
    > page.
    >
    > The code that gives an error is the following.
    >
    > if(!eregi($HTTP _HOST,$HTTP_REF ERER)) Error("Write in the normal way");
    >
    > The browser is IE 6.0 and I configured the options the same as other
    > computer.
    >
    > What's wrong?[/color]

    Possibly the HTTP_REFERER variable isn't being set. Is there something
    on that computer which might be prevented the referal information being
    passed?

    As an aside, you are better to use the $_SERVER superglobal array like
    so: $_SERVER['HTTP_HOST'] and $_SERVER['HTTP_REFERER'] as the use of
    $HTTP_HOST etc has been deprecated.

    You can never rely on $_SERVER['HTTP_REFERER'] being set so it is
    generally unsafe to rely on it. There are browser preferences and other
    3rd party apps that can prevent it being passed or otherwise altered.

    When using HTTP_REFERER you are best to check it is first set with the
    isset() function eg

    if(isset($_SERV ER['HTTP_REFERER'])) {
    ...
    }
    else {
    ...
    }

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

    Comment

    • Alvaro G. Vicario

      #3
      Re: Question about $HTTP_HOST, $HTTP_REFERER

      *** ssk@chol.net escribió/wrote (1 Feb 2005 08:53:56 -0800):[color=blue]
      > I made a web site using PHP Open sources for message board.
      > Everything's fine except one computer can't open a message writing
      > page.
      >
      > The code that gives an error is the following.
      >
      > if(!eregi($HTTP _HOST,$HTTP_REF ERER)) Error("Write in the normal way");[/color]

      Two remarks. First of all, the preferred way to call these variables is
      using the $_SERVER array:

      $_SERVER['HTTP_HOST']
      $_SERVER['HTTP_REFERER']

      Secondly, there's most likely an ad-blocking software or firewall that
      removes the referrer header from browser requests.


      --
      -+ Álvaro G. Vicario - Burgos, Spain
      +- http://www.demogracia.com (la web de humor barnizada para la intemperie)
      ++ Manda tus dudas al grupo, no a mi buzón
      -+ Send your questions to the group, not to my mailbox
      --

      Comment

      Working...