Nested Post Variable Arrays
Posted: Tue Jul 09, 2002 12:08 pm
Hello. I have a situation and was wanting some input on it.
I have a form that uses arrays for the inputs:
...
print "<INPUT TYPE='HIDDEN' NAME='id[]' VALUE='".OCIResult($stmt,1)."'>\n";
...
This is because I have no idea how many of these rows I will submit for update. Anyway, this approach works fine when I set my form action to submit to another page, which then does the updates and redirects to my original page. So I know the code as it stands works.
However, when I try to put this "form handler" into a function so I can distribute it amongst multiple pages, I run into problems when trying to utilize the form elements.
My form handler call is as such:
handle_form($HTTP_POST_VARS)
The function declaration is as such:
handle_form($form_vars)
Due to this arrangement, I seemingly have to handle the POST vars I passed in as:
$form_vars['key']
But this doesn't work with the form/input arrays I'm using:
$form_vars['$id[$count]']
and I can't access the values if I just use
$id[$count]
Can anybody tell me what I'm missing?
Thanks for your time.
I have a form that uses arrays for the inputs:
...
print "<INPUT TYPE='HIDDEN' NAME='id[]' VALUE='".OCIResult($stmt,1)."'>\n";
...
This is because I have no idea how many of these rows I will submit for update. Anyway, this approach works fine when I set my form action to submit to another page, which then does the updates and redirects to my original page. So I know the code as it stands works.
However, when I try to put this "form handler" into a function so I can distribute it amongst multiple pages, I run into problems when trying to utilize the form elements.
My form handler call is as such:
handle_form($HTTP_POST_VARS)
The function declaration is as such:
handle_form($form_vars)
Due to this arrangement, I seemingly have to handle the POST vars I passed in as:
$form_vars['key']
But this doesn't work with the form/input arrays I'm using:
$form_vars['$id[$count]']
and I can't access the values if I just use
$id[$count]
Can anybody tell me what I'm missing?
Thanks for your time.