imarockstar Posted June 26, 2009 Share Posted June 26, 2009 I will try to explain this as best as I can ... I have a Form which asks for general information from users. At this point there are about 15 questions. These questions are stored in a DB under the table 'gq', which stands fro GENERAL QUESTIONS. On the from page, the code I have written queries the database and then displays all the questions. Each question has its own ID. No problem there. The problem I am having is with the next page, the page that will take all the posts and then input them into the database. But we can start a little more simple then that. How can I simply get all the posts from the form and store them into variables. For instance .. If the form page is called general_questions.php and that page posts to gq_go.php how would I get the $_POST data and store them in a variable. Usually for each post value I do this : $username = $_POST['username']; But since the forms are dynamic, and we wil be adding questions on the fly, I can not know what each $_POST will be. Is there a way to dynamically generate all the : $username = $_POST['username']; does that make any since at all ? below is the form code : (without the <form></form> tags) <h2 class=''>General Information</h2> <br> <?php $sql="SELECT * FROM gq ORDER BY gq_id ASC"; $result=mysql_query($sql); while($rows=mysql_fetch_array($result)){ ?> <?php if ( $rows['gq_question'] !== '' ) { ?> <h2 class='question bluestatic'><? echo $rows['gq_question']; ?></h2> <? } ?> <div class="<? echo $rows['gq_style1']; ?>"> <? echo $rows['gq_fieldtitle']; ?> <bR> <!-- displays a text field if it is one --> <?php if ( $rows['gq_type'] == 1 ) { ?> <div class="<? echo $rows['gq_style']; ?>"> <input type="text" class="FMinput" name="<? echo $rows['gq_id']; ?>" > <Br> </div> <? } ?> <!-- displays a drop down if it is one --> <?php if ( $rows['gq_type'] == 2 ) { $a = explode(',', $rows['gq_options']); echo "<select class='FMselect'>"; foreach ($a as $v) { echo "<option>" . $v . "</option>"; } echo "</select>"; } ?> </div> <?php if ( $rows['gq_style2'] == 'endleft' ) { echo "<br class='clear'>"; } ?> <? } ?> <!-- database pull from GQ --> and here is a link to the actual form : http://franklinspirko.com/sites/questions/questions_general.php Link to comment https://forums.phpfreaks.com/topic/163770-help-with-grabbing-all-the-post-data-from-a-form/ Share on other sites More sharing options...
imarockstar Posted June 26, 2009 Author Share Posted June 26, 2009 what ? no one wants to tackle this one ? lol ... here is what I found ... it seams to work ... but .. it displays all the posts in a weird way ... how coudl I get this info into a database ? <?php echo "POST/GET Variables: "; foreach ($_POST as $key => $val) echo "$key =$val "; ?> Link to comment https://forums.phpfreaks.com/topic/163770-help-with-grabbing-all-the-post-data-from-a-form/#findComment-864140 Share on other sites More sharing options...
mattal999 Posted June 26, 2009 Share Posted June 26, 2009 <?php echo "POST Variables:<br />"; $myarray = array(); foreach ($_POST as $key => $val) { echo $key." = ".$val."<br />"; // Make some kind of array here. Just spitballing (Probably not even correct syntax): $myarray[] = $key; } print_r($myarray); ?> Link to comment https://forums.phpfreaks.com/topic/163770-help-with-grabbing-all-the-post-data-from-a-form/#findComment-864145 Share on other sites More sharing options...
imarockstar Posted June 26, 2009 Author Share Posted June 26, 2009 well this code works right here : <?php echo "POST/GET Variables: "; foreach ($_POST as $key => $val) echo "$val <br>"; ?> That prints out each POST on a separate line .. i am having trouble figuring out how to input the POST data into a database ... Link to comment https://forums.phpfreaks.com/topic/163770-help-with-grabbing-all-the-post-data-from-a-form/#findComment-864148 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.