Register globals


hello, i am tying to upload a wesite but i am getting the following error "Server Requirement Error: register_globals is disabled in your PHP configuration. This can be enabled in your php.ini configuration file or in the .htaccess file in your catalog directory."
where do i go to enable register globals or how to do it in .htaccess?
many thanks.


register_globals is disabled only on PHP5, so you can always switch your domain to use PHP4. However, it is best to rewrite your scripts to use the superglobal array variables instead. For example, if you have POSTed a form, the data can be found in the superglobal array $_POST.

Simon Jessey | Keystone Websites
Save $97 on yearly plans with promo code [color=#CC0000]SCJESSEY97[/color]


Don’t enable register_globals! If the site you have requires it, then I’d suggest getting a new website portal. Or contact the author of the backend script for your site and see if they have an update.

register_globals = bad.

Don’t need to explain any more than that. :slight_smile:

scjessey, I think it’s safe to assume the OP isn’t the programmer of the site. So he/she would have no clue what you’re talking about. :slight_smile:
The error they got can only come from some site configuration script. Which you can deduct they uploaded some kind of web portal and running through the install process. The install saw register_globals is disabled and requiring them to enable it.

yerba# rm -rf /etc


I prefer to assume that anyone posting here has at least some experience with the web. The disabling of register_globals is a relatively new phenomenon is web hostery, so there are an awful lot of canned scripts out there that require it to be enabled.

Simon Jessey | Keystone Websites
Save $97 on yearly plans with promo code [color=#CC0000]SCJESSEY97[/color]


Sad but true. It’s mostly lazy PHP programmers. has been saying to stop using register_globals since PHP4 (3 years) and even turned them off by default starting 4.1.

yerba# rm -rf /etc


to answer your question, you can either edit php.ini or use .htaccess as you have read.

to edit php.ini, first find out where it resides by viewing the output of this file via HTTP:

<?php phpinfo(INFO_GENERAL); ?> once you know where it is, you can edit it using vim:

vim /path/to/php.ini (i believe pico and nano are available alternatives as well)

while in vim, type this in to search for the register_globals directive:

<esc>+/+register_globals = escape key
the + signs are not literal. they just imply that you have to use a key combination
hit “n” to repeat the search.

once you’ve found register_globals, hit “i” to go into insert mode to enter text, change its value to “on”. it should be “off”.

now save and exit the document like this:

now for these changes to take place, you would have to restart apache because php.ini is parsed only once at startup. i doubt we are allowed to do that (i’m new to dreamhost, this is my first day)

the following is the .htaccess solution (i’m assuming you have php4):

<IfModule mod_php4.c> php_flag register_globals on </IfModule>

For further reference: How to change configuration settings

having said all that, avoid using register_globals. it can lead to many security issues and it’s truly not worth it because depending on if the variables have been thoroughly initialized and the nature of the code, your entire site/database can be wiped out.


Er… no you can’t. PHP is being run as a CGI binary, and nobody has access to php.ini unless they compile their own version.

Simon Jessey | Keystone Websites
Save $97 on yearly plans with promo code [color=#CC0000]SCJESSEY97[/color]


Editing PHP configs is not something I would recommend to anybody that doesn’t know how to use vim. No offense to new users, but I do require people to at least have a bit of linux knowledge before they go around editing server/application configuration files. :slight_smile:

I have nothing against new users. I help them whenever they need help. However, they must put forth the effort and questions themselves. I won’t let people go far enough ahead where they could get themselves in trouble (security wise and what ever else).

My recommendation still stands: Contact the original author of the portal script to see if there’s an updated script. Or use another script. Register globals is not something that should be enabled under any circumstances.

Experience with web is far different than experience with programming and linux. I know you know this very well. Doing the edits you’ve suggested goes into programming. And the above post by koobi goes into Linux. Compiling your own PHP also goes into Linux with a hint of programming (if something goes wrong).

yerba# rm -rf /etc


you do have the option to run PHP as an Apache module though. at least this is what i read in the wiki somewhere.


Only if you are using PHP4.

Simon Jessey | Keystone Websites
Save $97 on yearly plans with promo code [color=#CC0000]SCJESSEY97[/color]