note 77854 deleted from function.extract by nlopess
| From: | nlopess@php.net | Date: | Sun, 16 Sep 2007 09:48:11 +0000 |
| Subject: | note 77854 deleted from function.extract by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-130534@lists.php.net to get a copy of this message | ||
Note Submitter: robbiesmith79 at gmail dot com
Reason: bad code
----
I put two and two together tonight and thought what if...
extract($_POST);
Now all my form fields are now automatically translated into variable names
Example:
<form method="POST" action="<?php echo
$_SERVER['PHP_SELF'];?>">
<input type="text" name="myField1" value="">
<input type="text" name="myField2" value="">
<input type="text" name="myField3" value="">
<input type="submit" name="submit" value="Submit">
</form>
<?php
if ($_POST["submit"] != "") {
extract($_POST);
print $myField1 . ", " . $myField2 . ", and " . $myField3;
}
?>
Pretty cool stuff. I can't believe I didn't RTFriendlyM sooner!