note 33968 deleted from language.variables.external by danbrown
| From: | danbrown@php.net | Date: | Wed, 09 Mar 2011 14:42:22 +0000 |
| Subject: | note 33968 deleted from language.variables.external by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-177712@lists.php.net to get a copy of this message | ||
Note Submitter: nospam at thenerdshow dot calm
----
I've combined the method of converting old code suggested by solar at heliacal dot net into the
improved script below. This one works whether the submit is get or post and, as in my previous
contribution, sets any unsubmitted variables to null, preventing errors. This supercedes my
previous post below (if it hasn't been deleted yet).
$expected=array(
'name', // Only accept these variables from a submit!
'email',
'favorite_color'
); foreach ($expected as $formvar)
$$formvar = (isset(${"_$_SERVER[REQUEST_METHOD]"}[$formvar]))?
${"_$_SERVER[REQUEST_METHOD]"}[$formvar]:NULL;