Welcome to WebmasterWorld Guest from 54.166.227.36

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

$ SERVER['HTTP REFERER'] not working on the server ?

     
4:21 am on Apr 25, 2008 (gmt 0)

5+ Year Member



Hello forums!
Case:
In localhost: [PHP]$_SERVER['HTTP_REFERER'][/PHP] 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.

6:51 am on Apr 25, 2008 (gmt 0)

WebmasterWorld Senior Member eelixduppy is a WebmasterWorld Top Contributor of All Time 5+ Year Member



If there is no referrer in existence then this variable will not be defined and therefore if you try to do something with it, since it doesn't exist, you will get an error. You should always check to see if it is there first before you do anything with it:

if(isset($_SERVER['HTTP_REFERER']))
#do something
2:46 pm on Apr 25, 2008 (gmt 0)

WebmasterWorld Senior Member penders is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



If there is no referrer in existence then this variable will not be defined...

...The user may have typed the URL directly or the user agent might simply not be setting the referrer. But whether PHP actually reports an error (or 'notice' in this case) when you refer to $_SERVER["HTTP_REFERER"] (when it does not exist) may be due to the setting of error_reporting() or display_errors - the default settings of which may be different on different servers. It may work OK in this instance because PHP is defaulting the value to an empty string, but this may not be the intention of the programmer, hence the 'notice'/warning.

 

Featured Threads

Hot Threads This Week

Hot Threads This Month