Wednesday, September 23, 2009

How To Enable register_globals in PHP

Many web applications developed using PHP were created requiring that a certain php setting called register_globals be turned on, as PHP installed on servers came with this on by default.


PHP developers and web hosts quickly realized that having this setting on by default has several major security implications and started changing their settings to have register_globals off. The immediate effect was increased security, but a ton of broken php web applications. If your site ran one of these applications, you were now the proud owner of a web site that no longer worked.


In addition, you could no longer use any application that required that register_globals be on.



Luckily there is a simple solution to the problem in most cases, at least until an alternate web application or a patch for your site to run with register_globals off can be installed.


First check to see if you have what is called a .htaccess file in your web sites main directory (usually public_html or httpdocs). Either check for this file with your web host provided file manager or use your FTP client to login to your account and check.

Note: Some servers hide files with a period in front of them, so you may need to configure your FTP client to see these hidden files. See your FTP client help file for instructions on how to view hidden files.


If you locate the .htaccess file, edit it and add this to the very top of the file:

Code:
php_value register_globals 1 





If you do not already have a .htaccess file in your public_html or httpdocs directory follow these simple instructions:
  1. Create a text file on your computer called htaccess.txt
  2. Edit this text file and add the following line to it:

    Code:
    php_value register_globals 1 
  3. Save the text file
  4. Upload this text file via FTP to your web
  5. Rename htaccess.txt to .htaccess (note the period in front of the file name)
Now attempt to re-load your web page that requires register_globals to be on. It will now load without any issues.

No comments:

Post a Comment