Register Globals

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Register Globals

Postby JoJo86 » 05. May 2009 13:03

Hi

I am extremely new to PHP and I am attempting to follow tutorials using the Larry Ullman book (PHP and MySQL for Dynamic Web Sites).

I have only just started these tutorials and I have already got a snag :(

I need to be able to use $HTTP_USER_AGENT and $REMOTE_ADDR variables but they are not working on my computer. The book suggests changing the configuration of XAMPP to switch on Register Globals. I have searched around the net and found this can be done using the PHP.INI file under XAMPP\Apache\bin\.

However, it has come to my attention that I do not have this file (unless I am very blind!).

I installed this only his morning but I am using Vista so that could be causing the issue. I followed the guidelines of not installing it under ProgramFiles so it is under C:\XAMPP.

If there is another way of being able to use these variables can anyone let me know? Again, I am a complete novice so please reply in layman's terms :)

Thanks, Jo
JoJo86
 
Posts: 2
Joined: 05. May 2009 12:56

Re: Register Globals

Postby Wiedmann » 05. May 2009 13:18

I need to be able to use $HTTP_USER_AGENT and $REMOTE_ADDR variables but they are not working on my computer. The book suggests changing the configuration of XAMPP to switch on Register Globals.

Suggesting to enable register_globals is really worse...

The correct way is to use the (since 7 years) correct variables:
$HTTP_USER_AGENT -> $_SERVER['HTTP_USER_AGENT']
$REMOTE_ADDR -> $_SERVER['REMOTE_ADDR']
--> http://de.php.net/manual/en/reserved.variables.php

it has come to my attention that I do not have this file (unless I am very blind!).

With phpinfo() you can see, which "php.ini" your PHP is using.
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: Register Globals

Postby JoJo86 » 05. May 2009 14:26

Thank you very much for this handy piece of code :)

Does this mean that every time there is a predefined variable I should use $_SERVER instead?

Again, thank you very much
JoJo86
 
Posts: 2
Joined: 05. May 2009 12:56

Re: Register Globals

Postby Wiedmann » 05. May 2009 14:30

Does this mean that every time there is a predefined variable I should use $_SERVER instead?

Yes. Or $_GET or $_POST. (if you are dealing with forms)
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 37 guests