note 19737 added to language.variables.predefined
| From: | luciano_at_braziliantranslation dot net at php2 dot chek dot com | Date: | Sat, 09 Mar 2002 01:54:34 +0000 |
| Subject: | note 19737 added to language.variables.predefined | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-27543@lists.php.net to get a copy of this message | ||
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'].
--
http://www.php.net/manual/en/language.variables.predefined.php
http://master.php.net/manage/user-notes.php?action=edit+19737
http://master.php.net/manage/user-notes.php?action=delete+19737
http://master.php.net/manage/user-notes.php?action=reject+19737