Skip to main content
CafeWebmaster

Main navigation

  • Tools
    • MD5 converter
    • SHA1 converter
    • Base64 encode
    • Base64 decode
    • HTML entities encode
    • HTML entities decode
    • Raw url encode
    • Raw url decode
    • UTF8 encode
    • UTF8 decode
    • Unix Time to Human Date converter
    • Remove duplicate lines
    • Sort text lines
    • Backwards - Mirrored Text
    • PiRaTe tExT
    • Your IP Address & Hostname
  • Forums
  • Free PHP Scripts
    • Image watermark with PHP
    • Page generation time with PHP
  • CSS
    • CSS hidden left menu
    • CSS horizontal menu
  • Free Fonts
  • Image Editors
  • Tutorials
    • Check password strength / safety with PHP and Regex
    • Cómo hacer que su sitio web popular!
    • How2 make a website popular
    • How2 secure your website
    • Kennwort Sicherheit mit PHP und Regex Prüfen
    • Page generation time and http-referrers with php
    • Redirect webpages with HTML, PHP, .htaccess, Java+Script, CGI-Perl, ASP.NET and ColdFusion
  • New
User account menu
  • Log in

Breadcrumb

  1. Home

Register Globals Emulator for PHP

By php beginner, 3 June, 2009

If your webhosting turned register-globals off and you are still using a script/software which requires register-globals on you have a problem. But there is an easy solution: Just put this code at the top of your php script(s). Attention!!! "register_globals=on" means a huge security risk. Do not turn it on unless you know what are you doing!
Technorati Profile

foreach(array($_GET, $_POST, $_COOKIE) as $k=>$v){
foreach($v as $k2=>$v2){
$$k2 = $v2;
}
}

You can improve this to build a small web-firewall and prevent sql-injection etc. You can add some code and strip unwanted html-javascript tags with this.

  • Log in to post comments

Anonymous (not verified)

14 years 6 months ago

or just use:

extract($_REQUEST);

Alessandra58 (not verified)

14 years 5 months ago

Opinion

The best books search in electronic libraries. Searches in a huge amount of libraries, many new submitions every day.

Anonymous (not verified)

14 years 4 months ago

Having register_globals = on

Having register_globals = on does not mean a huge security risk. Also, the provided code does not emulate it properly so instead consider using an example from the manual:

http://php.net/manual/en/faq.misc.php#faq.misc.registerglobals

CafeWebmaster.com(CW) is a free online community for webdevelopers and beginners. Anybody can share their code, articles, tips, tutorials, code-examples or other webdesign related material on the site. Newbies can submit their questions and reply to existing questions. CW does not guarantee or warrant reliability of code, data and information published on the site. Use the site on your own risk. The site takes no responsibility of direct or indirect loss or any kind of harm to its users. The site also doesn't take responsibility of infected files or source code with any kind of infection or viruses, worms, spywares, malwares, trojan horses. CW reserves the right to edit, move, or delete any of content for any reason.