Quick Search for:  in language:    
PHP,POST,since,version,longer,pass,variables,
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
PHP Stats

 Code: 107,779. lines
 Jobs: 40. postings

 How to support the site

 
Sponsored by:

 
You are in:
 
Login





Latest Code Ticker for PHP.
Click here to see a screenshot of this code!RepleteSurveys
By Steve Schoenfeld on 1/7

(Screen Shot)

gameserver query
By tombuksens on 1/5


Random Password Generator
By Domenic Matesic on 1/3


Accessing MySQL with PHP
By Ahmed Magdy Ezzeldin on 1/1


Click here to see a screenshot of this code!Debug Window
By Hohl David on 12/30

(Screen Shot)

Click here to see a screenshot of this code!Add Google search technology to your site without Google branding.
By Sean Cannon on 12/29

(Screen Shot)

PHP System Function
By Ruben Benjamin on 12/29


Click here to put this ticker on your site!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!

Affiliate Sites



 
 
   

register_globals workaround

Print
Email
 

Submitted on: 8/5/2003 8:50:29 AM
By: lixlpixel  
Level: Beginner
User Rating: By 4 Users
Compatibility:PHP 4.0

Users have accessed this article 1745 times.
 

(About the author)
 
     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.

 
 
Terms of Agreement:   
By using this article, you agree to the following terms...   
1) You may use this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this article from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.
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)


Other 1 submission(s) by this author

 

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
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
8/5/2003 12:04:01 PM:Christian Mallette
Good code, however the best way of keeping your script compatible and secure would be to code it the good way.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/5/2003 4:39:20 PM:lixlpixel
that's totally right. and that's what i do now, when i start to code a script from scratch. but there are a million (very useful) scripts to download out there which were coded "the old way", and that's where this snippet jumps in ...
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/5/2003 5:01:04 PM:Christian Mallette
agreed :)
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/6/2003 3:04:04 PM:
If you didn't know, you can also enable "register_globals" in your php.ini file, which is disabled by default since 4.2.0. I'll give this a try, though ;)
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/6/2003 7:14:55 PM:
register_globals is off for good reasons, this is not the point. as long as you use 'old' scripts with PHP >= 4.2.0 this script is more than helpful. for the future leave register_globals off and start coding the clean way.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/11/2003 9:49:47 AM:Michael Bailey
Another thing you can do if you are using Apache is add the following line to the httpd.conf file or create a .htaccess file. php_flag register_globals on
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/3/2003 8:46:54 PM:Tristan Wells
While this does work its a huge security risk. When you use raw globals PHP loads them from where ever it can get it. So forms are easy to hack aswell as other things.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/13/2003 5:32:50 PM:UnholyAngl
ini_set('register_globals', true); wouldn't this do the same thing?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this article has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular article, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | PHP Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.