bobicles2 Posted April 14, 2010 Share Posted April 14, 2010 I have a HTML form for inserting an event into my database, everything works fine apart from inserting the date, i have broken the date down into 3 small drop down menus so that i could make sure it was inserting in the format so the function CURRENT_DATE would work. however, it doesnt seem to want to add my date! when i fill out the form it sends nothing to the database can anyone shed some light for me? or help the html form is <form name="form2" method="post" action="insert.php"> <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#DBDBDB"> <tr> <td colspan="3"><p align="center"><strong>Add Event </strong></p> <p> </p></td> </tr> <tr> <td width="59">Event</td> <td width="4">:</td> <td width="239"><input type="text" name="Event" /></td> </tr> <tr> <td>Genre</td> <td>:</td> <td><select name="Genre" size="1"> <option selected="selected" value="none">Genre</option> <option>Rock</option> <option>Pop</option> <option>Indie</option> <option>Electro</option> </select> </td> </tr> <tr> <td>Date</td> <td>:</td> <td> <select name="Date"> <option selected="selected">Year</option> <option>2010</option> <option>2011</option> <option>2012</option> <option>2013</option> <option>2014</option> <option>2015</option> <option>2016</option> <option>2017</option> <option>2018</option> <option>2019</option> <option>2020</option> <option>2021</option> <option>2022</option> <option>2023</option> <option>2024</option> <option>2025</option> <option>2026</option> <option>2027</option> <option>2028</option> <option>2029</option> <option>2030</option> </select> <select name="Date"> <option selected="selected">Month</option> <option>01</option> <option>02</option> <option>03</option> <option>04</option> <option>05</option> <option>06</option> <option>07</option> <option>08</option> <option>09</option> <option>10</option> <option>11</option> <option>12</option> </select> <select name="Date"> <option selected="selected">Day</option> <option>01</option> <option>02</option> <option>03</option> <option>04</option> <option>05</option> <option>06</option> <option>07</option> <option>08</option> <option>09</option> <option>10</option> <option>11</option> <option>12</option> <option>13</option> <option>14</option> <option>15</option> <option>16</option> <option>17</option> <option>18</option> <option>19</option> <option>20</option> <option>21</option> <option>22</option> <option>23</option> <option>24</option> <option>25</option> <option>26</option> <option>27</option> <option>28</option> <option>29</option> <option>30</option> <option>31</option> </select> </td> </tr> <tr> <td>Price</td> <td>:</td> <td><input type="text" name="Price" /></td> </tr> <tr> <td>Tickets</td> <td>:</td> <td><input type="text" name="Tickets" /></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="Submit" value="Submit" /></td> </tr> </table></td> </form> and here is the insert.php file <?php $con = mysql_connect("localhost","teamrend_rwowen","291Aug89"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("teamrend_rwowen", $con); $sql="INSERT INTO Events (Event, Genre, Date, Price, Venue, Tickets) VALUES ('$_POST[Event]','$_POST[Genre]','$_POST[Date]','$_POST[Price]','$_POST[Venue]','$_POST[Tickets]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "Thank You, Your Event has now been added to our Records"; mysql_close($con) ?> Link to comment https://forums.phpfreaks.com/topic/198494-drop-down-insert-help/ Share on other sites More sharing options...
AdRock Posted April 14, 2010 Share Posted April 14, 2010 You've not set any values to each of you options in the drop down menu Link to comment https://forums.phpfreaks.com/topic/198494-drop-down-insert-help/#findComment-1041576 Share on other sites More sharing options...
ScotDiddle Posted April 14, 2010 Share Posted April 14, 2010 bobicles2, I ran your code through my trusty Zend Studio 5.5 and found that date = 14, the day of the month... Select id date is used three times set up select id=Year, id=Month and id=Day. Then in insert.php, $date = $_POST['year'] . '-' . $_POST['Month'] . '-' . $_POST['Day']; Then insert $date into your table instead of $_POST['date'] Scot L. Diddle, Richmond VA Link to comment https://forums.phpfreaks.com/topic/198494-drop-down-insert-help/#findComment-1041589 Share on other sites More sharing options...
AdRock Posted April 14, 2010 Share Posted April 14, 2010 use mysql_real_escape_string on your $_POST variables also Link to comment https://forums.phpfreaks.com/topic/198494-drop-down-insert-help/#findComment-1041638 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.