homepage Welcome to WebmasterWorld Guest from 54.226.0.225
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

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




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

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.

 

eelixduppy




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

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

penders




msg:3635065
 2:46 pm on Apr 25, 2008 (gmt 0)

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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved