Jump to content

Strange error with $_POST array


wh0mprat

Recommended Posts

HI, everyone.

I don't seem to be able to access the keys in the $_POST associative array.

I have a script that dynamically generates a form. The form element
names are generated based on image filenames, so I can't just access
them the normal way in the form handler script. I tried looping through
the $_POST array like this:
[code]
foreach ($_POST as $key=>$value)
{

echo $key.'=>'.$value.'<br>';
}
[/code]
and i get this output:

0=>Pay
1=>Pay
2=>on
3=>on
4=>tn__DSC2602.jpg
5=>tn__DSC2603.jpg

Those numbers are where I expected to see the form element names. Can
anyond advise me on why this is happening?

Derek
Link to comment
Share on other sites

Well, the form is dynamically generated and looks like this right now

[code]
<FORM ACTION="ImageUpload3.php" METHOD="POST">
<INPUT type='checkbox' NAME='Include0' checked='true'>
<SELECT NAME='Tier0'>
<option value='US'>US</option>
<option value='EU' selected='selected'>Europe</option>
</SELECT>
<INPUT TYPE='INPUT' NAME='FileName0' VALUE='tn__DSC2795.jpg'>

<INPUT type='checkbox' NAME='Include1' checked='true'>
<SELECT NAME='Tier1'>
<option value='US'>US</option>
<option value='EU' selected='selected'>Europe</option>
</SELECT>
<INPUT TYPE='INPUT' NAME='FileName0' VALUE='tn__DSC2796.jpg'>
</FORM>
[/code]

The form element names are placeholders for now, numbered by an iteration counter. I'll be giving them more meaningful names later.

When I tried Ken's suggestion, I got this:

Array
(
    [0] => EU
    [1] => EU
    [2] => on
    [3] => on
    [4] => tn__DSC2795.jpg
    [5] => tn__DSC2796.jpg
)
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.