Jump to content
MakeWebGames

HTTP_X_FORWARDED_FOR'


Memnoch

Recommended Posts

I am a relatively new programmer to PHP and am designing a game based on MCCodes V2. The following script is causing my game to shoot up an error on any page that I display when trying to view my game for testing.

Is there a reason why or something I can do to stop it?

Notice: Undefined index: HTTP_X_FORWARDED_FOR in D:\domains\blackheartworks.com\wwwroot\anarchystreet\login.php on line 210

Notice: Undefined index: HTTP_X_FORWARDED_FOR in D:\domains\blackheartworks.com\wwwroot\anarchystreet\header.php on line 110

 

$IP = ($_SERVER['HTTP_X_FORWARDED_FOR'])

? $_SERVER['HTTP_X_FORWARDED_FOR']

: $_SERVER['REMOTE_ADDR'];

Please remember that I am relatively new at PHP.:S

Link to comment
Share on other sites

Re: HTTP_X_FORWARDED_FOR'

Try putting this somewhere in your script:

error_reporting(E_ERROR);

 

Or for debugging purposes, try this on a seperate script, then just post the output.

print_r($_SERVER);

Or just use HTTP_SEVER_VARS.

$IP = ($HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR']) ? $HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR'] : $HTTP_SERVER_VARS['REMOTE_ADDR'];

Just add HTTP_SERVER_VARS as a global when used in functions.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...