Notice: Undefined index: HTTP_X_FORWARDED_FOR

Hi

i use windows server 2008 and IIS7 with php 5.3 i have problem with this script:

[php]
if ($_SERVER[‘HTTP_X_FORWARDED_FOR’] == “127.0.0.1” || $_SERVER[‘HTTP_X_FORWARDED_FOR’] == “78.47.188.82”)
{
unset($_SERVER[‘HTTP_X_FORWARDED_FOR’]);
}
[/php]

My error:

[php]
Notice: Undefined index: HTTP_X_FORWARDED_FOR
[/php]

[member=46335]raminr63[/member]

That just means their is no such headers, paths, and script locations called “HTTP_X_FORWARDED_FOR” for that page that’s loading.

It seems that the person who wrote the script was removing his IP’s from being recorded.

You can just delete all that code and your application should run just fine.

If you don’t want to delete it, you’ll if to test to see if it exists first, like below.

[php] if (isset($_SERVER[‘HTTP_X_FORWARDED_FOR’])) {
if ($_SERVER[‘HTTP_X_FORWARDED_FOR’] == “127.0.0.1” || $_SERVER[‘HTTP_X_FORWARDED_FOR’] ==
“78.47.188.82”)
{
unset($_SERVER[‘HTTP_X_FORWARDED_FOR’]);
}
}[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service