[PHP] Grabbing ALL $_POST var at once.
The code below works (but its ugly), but I know there has to be a why to grab all the $_POST[] at once and then parse them out? Isn't there a why for me to access them directory without reassigning them? TIH, David ?php $From = $_POST['from']; $Two = $_POST['two']; $Subject = $_POST['sub_ject']; $Comments = $_POST['comments']; echo b$From/b;print \n; echo $Two;print \n; echo $Subject;print\n; echo $Comments;print \n; ? ?php mail($Two,$Subject,$Comments) ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Grabbing ALL $_POST var at once.
See either extract() or import_request_variables() in the manual. -Rasmus On Mon, 6 May 2002, David J Jackson wrote: The code below works (but its ugly), but I know there has to be a why to grab all the $_POST[] at once and then parse them out? Isn't there a why for me to access them directory without reassigning them? TIH, David ?php $From = $_POST['from']; $Two = $_POST['two']; $Subject = $_POST['sub_ject']; $Comments = $_POST['comments']; echo b$From/b;print \n; echo $Two;print \n; echo $Subject;print\n; echo $Comments;print \n; ? ?php mail($Two,$Subject,$Comments) ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Grabbing ALL $_POST var at once.
On Mon, 6 May 2002, David J Jackson wrote: The code below works (but its ugly), but I know there has to be a why to grab all the $_POST[] at once and then parse them out? Isn't there a why for me to access them directory without reassigning them? They're just variables. You can print them or use them as function arguments... ? mail ($_GET['to'], $_GET['subject'], Hey, {$_GET['comments']}) ? miguel ?php $From = $_POST['from']; $Two = $_POST['two']; $Subject = $_POST['sub_ject']; $Comments = $_POST['comments']; echo b$From/b;print \n; echo $Two;print \n; echo $Subject;print\n; echo $Comments;print \n; ? ?php mail($Two,$Subject,$Comments) ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Grabbing ALL $_POST var at once.
?php $From = $_POST['from']; $Two = $_POST['two']; $Subject = $_POST['sub_ject']; $Comments = $_POST['comments']; echo b$From/b;print \n; echo $Two;print \n; echo $Subject;print\n; echo $Comments;print \n; ? ?php mail($Two,$Subject,$Comments) ? Why do you waste time assigning a variable to a variable...Is it really that hard to just use the $_POST array? ?php echo b . $_POST[from] . /b\n; echo $_POST[two] . \n; echo $_POST[sub_ject] . \n; echo $_POST[comments] . \n; mail($_POST[two],$_POST[sub_ject],$_POST[comments]); ? If that's too hard to understand, use extract(). ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Grabbing ALL $_POST var at once.
Rasmus Lerdorf wrote: See either extract() or import_request_variables() in the manual. Rasmus -- I appreciate you taking the time to reply to my posting. David -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Grabbing ALL $_POST var at once.
John --- Thanks for your reply, but let me rephase the question. Let say I have a form with 50 fields on it do I have to: echo $_POST['one'] . . echo $POST['fifty'] Or should I, could I use extract()? Thanks in advance, David p.s I said it was UGLY :) ? If that's too hard to understand, use extract(). ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Grabbing ALL $_POST var at once.
On Mon, 6 May 2002, David J Jackson wrote: Thanks for your reply, but let me rephase the question. Let say I have a form with 50 fields on it do I have to: echo $_POST['one'] . . echo $POST['fifty'] Or should I, could I use extract()? You can use extract if you want, but be careful, because it has security implications. Make sure you explicitly declare starting values for all non-user-supplied variables within that scope at some point after calling extract. miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Grabbing ALL $_POST var at once.
Do you simply need to view all of the values passed through the form? In that case try something like.. foreach ($_POST as $name = $value) { echo $name. : .$value.br; } -Kevin - Original Message - From: David J Jackson [EMAIL PROTECTED] To: 1LT John W. Holmes [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Monday, May 06, 2002 1:07 PM Subject: Re: [PHP] Grabbing ALL $_POST var at once. John --- Thanks for your reply, but let me rephase the question. Let say I have a form with 50 fields on it do I have to: echo $_POST['one'] . . echo $POST['fifty'] Or should I, could I use extract()? Thanks in advance, David p.s I said it was UGLY :) ? If that's too hard to understand, use extract(). ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Grabbing ALL $_POST var at once.
extract() wouldn't do you any good here, you'd still have to use echo $one, echo $two, etc...so what are you gaining? If you just want the values displayed, use the foreach() method someone already posted. You can use implode() to combine the whole array in to a single string...if you need something more than that, let us know. With that many elements, maybe it's time to rethink your layout or naming conventions. ---John Holmes... - Original Message - From: David J Jackson [EMAIL PROTECTED] To: 1LT John W. Holmes [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Monday, May 06, 2002 3:07 PM Subject: Re: [PHP] Grabbing ALL $_POST var at once. John --- Thanks for your reply, but let me rephase the question. Let say I have a form with 50 fields on it do I have to: echo $_POST['one'] . . echo $POST['fifty'] Or should I, could I use extract()? Thanks in advance, David p.s I said it was UGLY :) ? If that's too hard to understand, use extract(). ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Grabbing ALL $_POST var at once.
As you know, $_POST exists. You can also assign groups of names to an array through your HTML form like so: input type=text name=bar[name] input type=text name=bar[doh] ... And then play with them, for example: extract($_POST['bar']); print I say $name and $doh; extract($_POST['bar'], EXTR_PREFIX_ALL, 'bar'); print I say $bar_name and $bar_doh; extract() is a pretty cool function with many options, read about extract here: http://www.php.net/extract And as already stated by others, import_request_variables() and $_REQUEST exist too. Regards, Philip Olson On Mon, 6 May 2002, 1LT John W. Holmes wrote: extract() wouldn't do you any good here, you'd still have to use echo $one, echo $two, etc...so what are you gaining? If you just want the values displayed, use the foreach() method someone already posted. You can use implode() to combine the whole array in to a single string...if you need something more than that, let us know. With that many elements, maybe it's time to rethink your layout or naming conventions. ---John Holmes... - Original Message - From: David J Jackson [EMAIL PROTECTED] To: 1LT John W. Holmes [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Monday, May 06, 2002 3:07 PM Subject: Re: [PHP] Grabbing ALL $_POST var at once. John --- Thanks for your reply, but let me rephase the question. Let say I have a form with 50 fields on it do I have to: echo $_POST['one'] . . echo $POST['fifty'] Or should I, could I use extract()? Thanks in advance, David p.s I said it was UGLY :) ? If that's too hard to understand, use extract(). ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php