Jump to content

Archived

This topic is now archived and is closed to further replies.

wh0mprat

Strange error with $_POST array

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

Share this post


Link to post
Share on other sites
I tried that before, but with all I've been doing, I forgot about that, so I gave it another shot.

The result is that the number  (array index, I suppose) disappears and i have output like this:

=>Pay
=>Pay
=>on
=>on
=>tn__DSC2602.jpg
=>tn__DSC2603.jpg

Share this post


Link to post
Share on other sites
Do the following:
[code]<?php
echo '<pre>' . print_r($_POST,true)  .'</pre>';
?>[/code]
What does the form look like?

Ken

Share this post


Link to post
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
)

Share this post


Link to post
Share on other sites

×

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.