wh0mprat Posted September 16, 2006 Share Posted September 16, 2006 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 elementnames are generated based on image filenames, so I can't just accessthem the normal way in the form handler script. I tried looping throughthe $_POST array like this:[code]foreach ($_POST as $key=>$value){ echo $key.'=>'.$value.'<br>';}[/code]and i get this output:0=>Pay1=>Pay2=>on3=>on4=>tn__DSC2602.jpg5=>tn__DSC2603.jpgThose numbers are where I expected to see the form element names. Cananyond advise me on why this is happening?Derek Quote Link to comment Share on other sites More sharing options...
AndyB Posted September 17, 2006 Share Posted September 17, 2006 Try echo [b]$$[/b]key.'=>'.$value ..... Quote Link to comment Share on other sites More sharing options...
wh0mprat Posted September 17, 2006 Author Share Posted September 17, 2006 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 Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted September 17, 2006 Share Posted September 17, 2006 Do the following:[code]<?phpecho '<pre>' . print_r($_POST,true) .'</pre>';?>[/code]What does the form look like?Ken Quote Link to comment Share on other sites More sharing options...
wh0mprat Posted September 17, 2006 Author Share Posted September 17, 2006 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) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.