Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Getting all the form args
Old 08-12-2004, 04:45 PM Getting all the form args
Average Talker

Posts: 15
Trades: 0
Hi - I'm looking for help in getting all form fields from a html form, not just those fields preceding a submit button click.

I have a form which has multiple submit buttons located throught the form. For exampe, it might reside in the middle of the form, again a lines later, and again a few lines later.

When I do a

while(list($key, $value) = each($HTTP_GET_VARS) )


I get the $key/$value pairs for everything up to an including the submit button. However, I can see from the browser location bar that ALL forms args are being submitted, not just the ones up to a submit button which might be located, for example, halfway thru my list of fields.

I'm looking for help with capturing each and every $key/$valuepair, not a truncated version. And I want these in an array, preferable two arrays, one called $keyarray, and one called $valluearray.

Thanks in advance :-)
new_PHP_er is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-12-2004, 09:13 PM
Junior Talker

Posts: 2
Trades: 0
Quote:
Originally Posted by new_PHP_er
Hi - I'm looking for help in getting all form fields from a html form, not just those fields preceding a submit button click.

I have a form which has multiple submit buttons located throught the form. For exampe, it might reside in the middle of the form, again a lines later, and again a few lines later.

When I do a

while(list($key, $value) = each($HTTP_GET_VARS) )


Try something like this:

PHP Code:

<?php

foreach ($_GET as $key=>$val)
{   
    echo 
"\$key = $key , \$val = $val <br />";
}   

?>

<form action="<?php $_SERVER['PHP_SELF']; ?>" method="get">

<input type="hidden" name="field1" value="this is field1" />

<input type="submit" name="submit1" value="this is submit1" />

<input type="hidden" name="field2" value="this is field2" />

<input type="submit" name="submit2" value="this is submit2" />

</form>

--ed
coo_t2 is offline
Reply With Quote
View Public Profile
 
Old 08-12-2004, 09:44 PM
Average Talker

Posts: 15
Trades: 0
That gave me this error:

Parse error: parse error, unexpected T_VARIABLE

Last edited by new_PHP_er; 08-12-2004 at 09:48 PM..
new_PHP_er is offline
Reply With Quote
View Public Profile
 
Old 08-12-2004, 09:58 PM
Average Talker

Posts: 15
Trades: 0
this seemed to work ...

$form_fields = array_keys($HTTP_GET_VARS);
for ($i = 0; $i < sizeof($form_fields); $i++) {

$thisField = $form_fields[$i];
$thisValue = $HTTP_GET_VARS[$thisField];
echo $thisField ." = ". $thisValue;
echo "<br />";

}
new_PHP_er is offline
Reply With Quote
View Public Profile
 
Old 08-12-2004, 10:01 PM
Junior Talker

Posts: 2
Trades: 0
Quote:
Originally Posted by new_PHP_er
That gave me this error:

Parse error: parse error, unexpected T_VARIABLE
Hmm, that's weird, it parsed alright for me. What version of PHP you using?

--ed
coo_t2 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Getting all the form args
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.28069 seconds with 12 queries