note 33985 added to function.import-request-variables
| From: | nospam at rack1 dot php dot net | Date: | Sat, 12 Jul 2003 22:25:39 +0000 |
| Subject: | note 33985 added to function.import-request-variables | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-51987@lists.php.net to get a copy of this message | ||
Thanks for all the suggestions. This is how I import variables when I want to keep the same name,
without a prefix, yet still maintain the security of only allowing certain variables into the scope.
This one accepts input from post, get and cookie while setting any unsubmitted variables to NULL,
preventing errors. Just one issue: You can use if ($email) to check for null but if
($email=="") doesn't seem to work. If you prefer to do your checks that way then
change NULL to "" in this example:
$expected=array(
'name', // Only accept these variables from a submit!
'email',
'favorite_color'
); foreach ($expected as $formvar)
$$formvar = (isset($_REQUEST[$formvar]))?$_REQUEST[$formvar]:NULL;
----
Manual Page -- http://www.php.net/manual/en/function.import-request-variables.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+33985
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+33985&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+33985&report=yes