phppup Posted February 22, 2012 Share Posted February 22, 2012 I have a form with a table that contains ONLY dropdown menus for users to select quantities from 25 dinner items. It contains some Javascript, but nothing fancy. In an effort to establish my database and TEST to see how some PHP functions might respond so I could improve my form, I created a mini version of the db in MySQL. But when I click the submit button, the page blinks, the address bar fills with field names, but there is no connect. No error messages. No data transfer. NO NOTHING! I searched the web and copied a form and plugged it in (an html form, a php insert file, and a MySQL database) and it worked fine. I peared down my page to mirror it, and still, no success. What little detail am I missing?? If I have 25 fields but create a db for the first 6, should it function? If I reduce it and try to re-use the same db, am I persuing a problem? I've tried error trapping and changing the form inputs, but it just still doesn't connect. Please help! Quote Link to comment https://forums.phpfreaks.com/topic/257500-am-i-missing-a-minor-detail/ Share on other sites More sharing options...
trq Posted February 22, 2012 Share Posted February 22, 2012 What little detail am I missing?? How should we know? Post some relevant code. Quote Link to comment https://forums.phpfreaks.com/topic/257500-am-i-missing-a-minor-detail/#findComment-1319784 Share on other sites More sharing options...
phppup Posted February 22, 2012 Author Share Posted February 22, 2012 The HTML looks something like this all the way throuogh: <tr><td> <select name="brisket"> <option value="0.00" selected> --- </option> <option value="1.00"> 1 </option> <option value="2.00"> 2 </option> <option value="3.00"> 3 </option> <option value="4.00"> 4 </option> <option value="5.00"> 5 </option> <option value="6.00"> 6 </option> <option value="7.00"> 7 </option> <option value="8.00"> 8 </option> <option value="9.00"> 9 </option> <option value="10.00">10 </option> </select></td><td>BRISKET OF BEEF</td><td>32.00 LB</td><td>ujiujjpooj</td><td> <!-- FILLER --> </td> <td> <select name="carrots"> <option value="0.00" selected> --- </option> <option value="1.00"> 1 </option> <option value="2.00"> 2 </option> <option value="3.00"> 3 </option> <option value="4.00"> 4 </option> <option value="5.00"> 5 </option> <option value="6.00"> 6 </option> <option value="7.00"> 7 </option> <option value="8.00"> 8 </option> <option value="9.00"> 9 </option> <option value="10.00">10 </option> </select></td><td>CARROTS</td><td> and my PHP is here: <?php require('connection.php'); mysql_connect("$hostname", "$username", "$password") or die ('Unable to connect to database!); mysql_select_db("$database") or die('Could not connect to db: ' . mysql_error()); if(isset($_POST['action']) && $_POST['action'] == 'submitform') { $roastturkey = $_POST['roastturkey']; $broccoli = $_POST['broccoli']; $brisket = $_POST['brisket']; $carrots = $_POST['carrots']; $EZchix_sum= $_POST['EZchix_sum']; $chixcutlet = $_POST['chixcutlet']; $chixfingers = $_POST['chixfingers']; $strgbalmond_sum=$_POST['strgbalmond_sum']; $strgbalmond1 = $_POST['strgbalmond1']; $strgbalmond2 = $_POST['strgbalmond2']; $strgbalmond3 = $_POST['strgbalmond3']; } $sql = "INSERT INTO dinnertable (roastturkey,broccoli,brisket,carrots,chixcutlet,chixfingers,strgbalmond1,strgbalmond2,strgbalmond3) VALUES ('','$roastturkey','$broccoli','$brisket','$carrots','$chixcutlet','$chixfingers','$strgbalmond1','$strgbalmond2','$strgbalmond3')"; $result=mysql_query($sql); // if successfully insert data into database, displays message "Successful". if($result){ echo "Successful"; else { echo "ERROR"; } > I just noticed that the feature for the TOTAL chicken and strgbalmond were being carried in the address bar. They are not important for my database, but maybe i needfields for them anyway???? Anditionally, I created a simple form with one field and a submit and ran it through my insert script and I got a successful connection and error message. Then I re-wrote my button on this form, and still no connection. Is the something about HTML 'selects' that I'm missing? Or a PHP comma or quote?? Quote Link to comment https://forums.phpfreaks.com/topic/257500-am-i-missing-a-minor-detail/#findComment-1319789 Share on other sites More sharing options...
Pikachu2000 Posted February 22, 2012 Share Posted February 22, 2012 But when I click the submit button, the page blinks, the address bar fills with field names . . . What little detail am I missing?? Your form's method attribute needs to be post. Quote Link to comment https://forums.phpfreaks.com/topic/257500-am-i-missing-a-minor-detail/#findComment-1319790 Share on other sites More sharing options...
litebearer Posted February 22, 2012 Share Posted February 22, 2012 Also you fields/values count is off.. $sql = "INSERT INTO dinnertable (roastturkey,broccoli,brisket,carrots,chixcutlet,chixfingers,strgbalmond1,strgbalmond2,strgbalmond3) VALUES ('','$roastturkey','$broccoli','$brisket','$carrots','$chixcutlet','$chixfingers','$strgbalmond1','$strgbalmond2','$strgbalmond3')"; 9 fields vs 10 values IF first field is an auto increment field no need to list it in the values Quote Link to comment https://forums.phpfreaks.com/topic/257500-am-i-missing-a-minor-detail/#findComment-1319795 Share on other sites More sharing options...
phppup Posted February 22, 2012 Author Share Posted February 22, 2012 My form begins with: <form name="orderpage" action="passpost.php" method="post"> <table> OOPS!!! never mind. Now I feel stupid. Been staring at this for 6 hours, and when I cut and pasted the code I noticed I had 2 form tags, so the submit was actually outside the process. Now I'm fine. This is why I'm just a PUP (or PUPIL) at this point. Sometimes you just need a second set of eyes to see it! Thanks for the assist. Quote Link to comment https://forums.phpfreaks.com/topic/257500-am-i-missing-a-minor-detail/#findComment-1319796 Share on other sites More sharing options...
phppup Posted February 22, 2012 Author Share Posted February 22, 2012 STill, I haven't actually CONNECTED and POSTED. Do I need to include fields for the strg and chick TOTALS? will the database accept PARTIAL data from a form that has 25 field with only 6 being populated for testing? Quote Link to comment https://forums.phpfreaks.com/topic/257500-am-i-missing-a-minor-detail/#findComment-1319798 Share on other sites More sharing options...
litebearer Posted February 22, 2012 Share Posted February 22, 2012 Yes Quote Link to comment https://forums.phpfreaks.com/topic/257500-am-i-missing-a-minor-detail/#findComment-1319826 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.