amjohnno Posted August 18, 2007 Share Posted August 18, 2007 There is probably an extremely simple answer to this but I can't seem to get my head around it. Basically I have a form dynamically created by results from a database. As such it's going to be different ever time it's used. For each row in the database I want to have a drop-down list. So my HTML form looks like this: <form id="formid" name="formname" method="POST" action="page.php"> <table border="0" cellspacing="0" cellpadding="0"> <tr> <td>Text 1</td> <td>Text 2</td> <td> <select name="reference_to_unique_database_id"> <option value="7" selected="selected">Seven</option> <option value="6">Six</option> <option value="5">Five</option> <option value="4">Four</option> <option value="3">Three</option> <option value="2">Two</option> <option value="1">One</option> </select> </td> </tr> <tr> <td>Text 1</td> <td>Text 2</td> <td> <select name="reference_to_unique_database_id"> <option value="7" selected="selected">Seven</option> <option value="6">Six</option> <option value="5">Five</option> <option value="4">Four</option> <option value="3">Three</option> <option value="2">Two</option> <option value="1">One</option> </select> </td> </tr> [etc...] <tr> <td colspan="3"><input type="submit" value="Update" /></td> </tr> </table> </form> My question is, once I've submitted the form how would I gather the information using php given that each time the form is submitted the names of the form elements are going to be different? Quote Link to comment https://forums.phpfreaks.com/topic/65590-solved-accessing-dynamically-created-html-forms/ Share on other sites More sharing options...
MadTechie Posted August 18, 2007 Share Posted August 18, 2007 use $_SERVER['REQUEST_URI'] // or $_SERVER['QUERY_STRING'] // or foreach($_POST as $K => $V) { echo $K." => ".$V; } Quote Link to comment https://forums.phpfreaks.com/topic/65590-solved-accessing-dynamically-created-html-forms/#findComment-327491 Share on other sites More sharing options...
Fadion Posted August 18, 2007 Share Posted August 18, 2007 If im getting your question right then the answer is simple. All the dynamically created post keys and values may be accessed by the $_POST superglobal. U can use print_r($_POST) to print out all the keys and their specific values. Quote Link to comment https://forums.phpfreaks.com/topic/65590-solved-accessing-dynamically-created-html-forms/#findComment-327493 Share on other sites More sharing options...
amjohnno Posted August 18, 2007 Author Share Posted August 18, 2007 That is exactly what I was looking for! (I knew it would turn out to be something simple!) Many thanks Quote Link to comment https://forums.phpfreaks.com/topic/65590-solved-accessing-dynamically-created-html-forms/#findComment-327494 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.