Pulling variables from $_POST
| From: | Barry L. Jeung | Date: | Tue, 22 Apr 2003 02:55:48 +0000 |
| Subject: | Pulling variables from $_POST | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-144755@lists.php.net to get a copy of this message | ||
Ok guys, haven't touched PHP in a while, and I just picked up an old
project I started awhile back. (prior to the 4.1.x default of
register_globals off). I've been familiarizing myself with ways to redo
some things in my old scripts, but I've run into a block (probably just
a mind block) and was hoping someone can help. I'm taking form data and
entering into my db. My old query was this:
$query = "update table set Name = '$Name', Email = '$Email', Phone =
'$Phone', Fax = '$Fax', Notes = '$Notes' where ID =
'$id'";
My new query is this:
$query = "update table set Name = " . $_POST["Name"] . " , Email = " .
$_POST["Email"] . " , Phone = " . $_POST["Phone"] . "
, Fax = " . $_POST["Fax"] . " , Notes = " . $_POST["Notes"] .
" where
ID = " . $_POST["id"];
Now that I've gotten this far, I'm not looking forward to redoing all my
other queries, nor typing all that crap in for each new query. So my
question is; is there a way to pull the $_POST data into an array or
some how reassign it to the original variables like so "$Name =
$_POST["Name"]" but without doing that manually. I'm sure there is some
sort of loop or other way of expanding that data, but this is my first
day back and I'm at wit's end. More than happy to read and explanation
if someone has a quick link, rather than typing a full explanation here.
Thanks for your time.