article

register_globals workaround

Email
Submitted on: 1/1/2015 6:06:00 PM
By: lixlpixel (from psc cd)  
Level: Beginner
User Rating: By 4 Users
Compatibility: PHP 4.0
Views: 1106
 
     since PHP version 4.2.0 you can no longer pass variables from one page to the other with a form without using the super-global variables $_POST or $_GET. These were introduced for security reasons, but it makes upgrading your old scripts a pain. imagine having to go through all the files on your server, changing hundreds of variables... with this script this problem is gone in no time.

 
				put following code
<?
if ( phpversion() >="4.2.0") extract($_POST);
?>
or if you're not sure where your variables come from <?
if ( phpversion() >= "4.2.0")
{
 extract($_POST);
 extract($_GET);
 extract($_SERVER);
 extract($_ENV);
 extract($_COOKIE);
}
?>
on top of your old script (or better put it in a file included in every page of your script) and you're all set. (sometimes life can be sooo easy)


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Beginner category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)
 

To post feedback, first please login.