will_fluke Posted April 22, 2007 Share Posted April 22, 2007 Someone must know what im doing wrong, here is the html file: <html> <head> <script type ="text/javascript"> function blanks() { form1.reset() } function validate() { <title>Audi Form Document</title> Customer_ID = document.form1.Customer_ID.value Title = document.form1.s1.options[form1.s1.selectedIndex].text Forename = document.form1.Forename.value Surname = document.form1.Surname.value Address_1 = document.form1.Address_1.value Address_2 = document.form1.Address_2.value Postcode = document.form1.Postcode.value Day = document.form1.s2.options[form1.s2.selectedIndex].text Month = document.form1.s3.options[form1.s3.selectedIndex].text Time = document.form1.s4.options[form1.s4.selectedIndex].text if((Customer_ID_i=="")||(Forename=="")||(Surname=="")||(Address_1=="")||(Address_2=="")||(Postcode=="")||(Day=="")||(Month=="")||(Time=="")) { alert("Missing Details") } else { alert(Customer_ID+"\n"+Title1+ " "+Forename.substring(0,1).toUpperCase()+""+Surname.toUpperCase()+"\nADDRESS: "+Address_1+"\n"+Address_2+"\n"+Postcode+"\n"+Day+"\nMONTH: "+Month+"\nTIME: "+Time) </script> </head> <body> <form name="form1" onSubmit="return validate()" action="AddBooking.php" method = "post"> <b>Title</b> <select title1="select"id="s1"> <option value="mr">Mr</option> <option value="mrs">Mrs</option> <option value="ms">Ms</option> <option value="dr">Dr</option> </select> </br> <b>Customer Number</b><input name="Customer_ID" type="text" id="Customer_ID"></br> <b>Forename</b><input name="Forename" type="text" id="Forename"></br> <b>Surname</b><input name="Surname" type="text" id="Surname"></br> <b>Street</b><input name="Address Line 1" type="text" id="Address_1"></br> <b>Town</b> <input name="Address Line 2" type="text" id="Address_2"></br> <b>Postcode</b><input name="Postcode" type="text" id="Postcode"></br> Day of Drive <select Day ="select"id="s2"> <option Value ="1">1st</option> <option Value ="2">2nd</option> <option Value ="3">3rd</option> <option Value ="4">4</option> <option Value ="5">5</option> <option Value ="6">6</option> <option Value ="7">7</option> <option Value ="8">8</option> <option Value ="9">9</option> <option Value ="10">10</option> <option Value ="11">11</option> <option Value ="12">12</option> <option Value ="13">13</option> <option Value ="14">14</option> <option Value ="15">15</option> <option Value ="16">16</option> <option Value ="17">17</option> <option Value ="18">18</option> <option Value ="19">19</option> <option Value ="20">20</option> <option Value ="21">21</option> <option Value ="22">22</option> <option Value ="23">23</option> <option Value ="24">24</option> <option Value ="25">25</option> <option Value ="26">26</option> <option Value ="27">27</option> <option Value ="28">28</option> <option Value ="29">29</option> <option Value ="30">30</option> <option Value ="31">31</option> </select> </br> Month of Drive <select Month ="select"id="s3"> <option Value ="January">Jan</option> <option Value ="Febuary">Feb</option> <option Value ="March">Mar</option> <option Value ="April">Apr</option> <option Value ="May">Mar</option> <option Value ="June">Jun</option> <option Value ="July">Jul</option> <option Value ="August">Aug</option> <option Value ="September">Sep</option> <option Value ="October">Oct</option> <option Value ="November">Nov</option> <option Value ="December">Dec</option> </select> </br> Time <input name="Time" type="text" id="Time"> <center><input type="submit" name="submit" value="submit" onClick="validate()"> <input type="button" name="Button" value="Reset" onClick="blanks()"></center> </form> </body> </html> And Here is The PHP File which loads to sql server minus ,Address_1,Address_2, which im none to bothered about, the fields that are makin me swear are all the select boxes, there must be an easy Answer HELP! <html> <head> <title>Audi Bookings</title> </head> <body> <h1>Test Drive Bookings</h1> <?php // create short variable name $Customer_ID=$HTTP_POST_VARS['Customer_ID']; $Title=$HTTP_POST_VARS['s1']; $Forename=$HTTP_POST_VARS['Forename']; $Surname=$HTTP_POST_VARS['Surname']; $Address_1=$HTTP_POST_VARS['Address_1']; $Address_2=$HTTP_POST_VARS['Address_2']; $Postcode=$HTTP_POST_VARS['Postcode']; $Day=$HTTP_POST_VARS['s2']; $Month=$HTTP_POST_VARS['s3']; $Time=$HTTP_POST_VARS['Time']; @ $db = mysql_connect('mysql.bsccomputing.net', 'pc121', 'pc12107'); if (!$db) { echo 'Error: Could not connect to database. Please try again later.'; exit; } else { mysql_select_db('pc121'); $query = "insert into Booking(Customer_ID,Title,Forename,Surname,Address_1,Address_2,Postcode,Day,Month,Time) values ('$Customer_ID','$Title','$Forename','$Surname','$Address_1','$Address_2','$Postcode','$s2.Day','$Month','$Time')"; $result = mysql_query($query); if ($result) echo 'Test Drive inserted'; else echo 'Did not work'; } ?> <p>Click <a href="AudiFORM1.html">here</a> to return to the login page</font></p> </body> </html> Quote Link to comment Share on other sites More sharing options...
HIV Posted April 22, 2007 Share Posted April 22, 2007 What's the problem? Quote Link to comment Share on other sites More sharing options...
will_fluke Posted April 22, 2007 Author Share Posted April 22, 2007 The problem is the select boxes s1,s2, etc are not uploading to the database! Quote Link to comment Share on other sites More sharing options...
Jaquio Posted April 22, 2007 Share Posted April 22, 2007 Don't use ID="s1",etc instead use name="s1" Quote Link to comment Share on other sites More sharing options...
neel_basu Posted April 22, 2007 Share Posted April 22, 2007 ::)HIV is asking a Human beings "Hey whats your problem" Quote Link to comment Share on other sites More sharing options...
AbydosGater Posted April 22, 2007 Share Posted April 22, 2007 Why do you have this topic twice? Please dont post the same topic over. And as far as i know Barand answered this question in the other topic. Andy Quote Link to comment Share on other sites More sharing options...
AndyB Posted April 22, 2007 Share Posted April 22, 2007 Change '$s2.Day' to '$Day' in your $query definition. Change echo 'Did not work'; to echo mysql_error(); Use the html select properly; This <select Day ="select"id="s2"> has no NAME defined, which is why it refuses to show up in the POSTed array <select name="s2"> .. that'll work Fix the other select dropdown as well. Quote Link to comment Share on other sites More sharing options...
neel_basu Posted April 22, 2007 Share Posted April 22, 2007 That big post and long codes was not needed for this small problem. Next time Please dont post unnecessay Codes. 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.