PHP variables arn't working for you? read this.

DirectAdmin Support

Administrator
Staff member
Joined
Feb 27, 2003
Messages
9,158
PHP variables aren't working for you? Read this.

Hello,

This is just a note to all php users, that by default, registerglobals is set to off. What this means is that if you have a php page, when you run:

page.php?name=gary

$name will *not* hold the value of gary in your script. What you need to do is use the $_GET array:

$_GET['name']

(or $_POST['name'] if you've passed it via POST)

This is something that php.net is pushing towards, as registerglobals=on can be a security risk if the scripts are programmed poorly.

If you *must* have it on, then contact your host and have him change the php.ini to turn it on.

John
 
Keeping registerglobals on is for wimps ;). Real men validate where their input is coming from, so people don't fsck up their websites :)!
 
I agree 100% keep it off by default. Server is more secure that way which means less headache for the admin.

However, like any good programmer I'm lazy. If I come across a good script that I want to use but it's got bad programming, I'm not gonna spend a few days fixing it, I might need to use it right away. Plus that would be a lot like work.

So to fix it JUST for that script. Simply put a .htaccess in the directory that the script is in, that has a line like this:

php_value register_globals 1
 
some customers want to have Register_global 'on'. How can I do that?
 
put a file in their HTML directory named .htaccess and put the following line in it:

php_value register_globals 1

Chris
 
Back
Top