Consider this:
Values that are supposed to be passed from user:
username and password
Now, consider this code (with register_globals on):
if ($username == "me" && $password == "this") {
$authorized = true;
}
if ($authorized) {
print "secret info!! Confidential";
}
Now, if the user has knowledge about the script, he/she can pass authorized as the parameter, as in:
script.php?authorized=1
and even without username and password, the script would print out secret information!!
But now consider this code (with register globals off):
if ($POST['username'] == "me" && $POST['password'] == "this") {
$authorized = true;
}
if ($authorized) {
print "secret info!! Confidential";
}
Now, even if the user said
script.php?authorized=1,
register_globals is not on, therefore $authorized will be undefined and secret info won't be printed!
Hope this helps,
Diego