note 19737 deleted from language.variables.predefined by didou
| From: | didou@php.net | Date: | Wed, 15 Oct 2003 17:36:06 +0000 |
| Subject: | note 19737 deleted from language.variables.predefined by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-58657@lists.php.net to get a copy of this message | ||
Note Submitter: luciano_at_braziliantranslation.net
----
This should be ridiculously obvious, but the superglobals are a new thing and could easily become
one of those little stupid things we sometimes overlook. I know I did:
If you turn off register globals and start using the new "superglobals", remember that
whatever comes from a form is now an element of either the $_POST or $_GET array. It's no
longer a variable. For example: if you have a form with the "name" and "email"
fields and use the POST method, they're going to be $_POST['name'] and
$_POST['email'], respectively. $name and $email do not exist unless you create them in the
script that is receiving the form data.
They can be created for checking purposes. For example:
if (!empty($_POST['email']))
{$email = 'ok';}
if ($email != 'ok')
{echo 'You forgot to provide your e-mail address';}
In other words, since the variable has nothing to do with its namesake array element, except perhaps
your own and intended use of both in some form of idea association, you can safely change the value
of $email or do anything else with it without the risk of messing with $_POST['email'].