Jump to content

register global


nawad24

Recommended Posts

we just found out that our web hosts turned off the register globals on their servers and that is the reason our site has stopped functioning.  they said we need to also turn it off on our end.  i have no idea how to do this (we are a non profit and don't have someone on site to do this.)  can anyone provide a quick tutorial or point me in the right direction?  thanks!

 

Link to comment
Share on other sites

I assume by "turn if off your end" they meant that you need to make your code compatible with the settting off. If they are hosting your website and have turned off the setting then there is nothing to "turn off".

 

If you have no real interest in security, and really just want a fix to make the site work, then adding the following bit of code to the top of your scripts should sort it out for you:

 

<?php
extract($_POST);
extract($_GET);
extract($_SERVER);
extract($_SESSION);
extract($_COOKIE);
?>

 

If you'd rather fix the code properly, i suggest you read up a little about the register_globals setting. Here would be a good place to start:

http://uk.php.net/register_globals

 

If you do intend to retrieve the variables from their respective superglobal arrays, e.g.:

 

<?php
$var = $_POST['var'];
?>

 

Then it may be advantageous to add in this piece of code:


error_reporting(E_ALL);

 

To the top of your php files. This will make sure you receive notices for undefined variables - which is what all of the variables that are being used without being retrieved from their respective arrays will be. However, (and hence the underling of the may) it could be that the code was not written particularly well, and you'll run into other notices which may confuse the issue whilst not affecting the running of the script.

 

I hope some of that helps.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.