title: Insert date into MySQL
body: <p>My website is simple, all I want to do is insert a date that I chose in a date picker into MySQL. (at the moment its inserting like this "0000-00-00 00:00:00").</p>
  
  <p>My PHP/HTML code is:</p>
  
  <pre><code>&lt;form id="form_351400" class="appnitro"  method="post" action="insert.php"&gt;
      &lt;div class="form_description"&gt;
          &lt;div style="width:100%;border:0px solid #000;"&gt;
              &lt;div style="float:left; width:75%;"&gt;
  
                  &lt;h2 align="left"&gt;Samurai Digital d.o.o.&lt;/h2&gt;
                  &lt;p&gt;
                      Maintenance Team
                  &lt;/p&gt;
              &lt;/div&gt;
              &lt;div style="float:left; width:25%;"&gt;
                  &lt;a href="index.php"&gt;&lt;img src="samurai.png" alt="Samurai" width="150" height="150" /&gt;&lt;/a&gt;
              &lt;/div&gt;
              &lt;div style="clear:both;"&gt;&lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;ul &gt;
          &lt;li id="li_0" &gt;
              &lt;label class="description" for="element_0"&gt;Insert into DB &lt;/label&gt;
              &lt;br/&gt;
          &lt;/li&gt;
          &lt;li id="li_1" &gt;
              &lt;label class="description" for="element_1" name="id" &gt;ID &lt;/label&gt;
              &lt;input type="text" name="id" /&gt;
          &lt;/li&gt;
          &lt;li id="li_2" &gt;
              &lt;label class="description" for="element_3"&gt;Date &lt;/label&gt;
              &lt;span&gt;
                  &lt;input id="element_3_1" name="element_3_1" class="element text" size="2" maxlength="2" value="" type="text"&gt;
                  / &lt;label for="element_3_1"&gt;MM&lt;/label&gt; 
              &lt;/span&gt;
              &lt;span&gt;
                  &lt;input id="element_3_2" name="element_3_2" class="element text" size="2" maxlength="2" value="" type="text"&gt;
                  / &lt;label for="element_3_2"&gt;DD&lt;/label&gt; 
              &lt;/span&gt;
              &lt;span&gt;
                  &lt;input id="element_3_3" name="element_3_3" class="element text" size="4" maxlength="4" value="" type="text"&gt;
                  &lt;label for="element_3_3"&gt;YYYY&lt;/label&gt; 
              &lt;/span&gt;
              &lt;span id="calendar_3"&gt; &lt;img id="cal_img_3" class="datepicker" src="calendar.gif" alt="Pick a date."&gt; &lt;/span&gt;
              &lt;script type="text/javascript"&gt;
                  Calendar.setup({
                      inputField : "element_3_3",
                      baseField : "element_3",
                      displayArea : "calendar_3",
                      button : "cal_img_3",
                      ifFormat : "%B %e, %Y",
                      onSelect : selectDate
                  });
              &lt;/script&gt;
          &lt;/li&gt;
          &lt;li id="li_3" &gt;
              &lt;label class="description" for="element_2" name="refid" &gt;Refid &lt;/label&gt;
              &lt;input type="text" name="refid" /&gt;
          &lt;/li&gt;
          &lt;li id="li_4" &gt;
              &lt;label class="description" for="element_4" name="classification" &gt;Classification &lt;/label&gt;
              &lt;select name="classification"&gt;
                  &lt;option value="SECRET"&gt;SECRET&lt;/option&gt;
                  &lt;option value="SECRET//NOFORN"&gt;SECRET//NOFORN&lt;/option&gt;
                  &lt;option value="CONFIDENTIAL"&gt;CONFIDENTIAL&lt;/option&gt;
                  &lt;option value="CONFIDENTIAL//NOFORN"&gt;CONFIDENTIAL//NOFORN&lt;/option&gt;
                  &lt;option value="UNCLASSIFIED"&gt;UNCLASSIFIED&lt;/option&gt;
                  &lt;option value="UNCLASSIFIED//FOR OFFICIAL USE ONLY"&gt;UNCLASSIFIED//FOR OFFICIAL USE ONLY&lt;/option&gt;
              &lt;/select&gt;
          &lt;/li&gt;
          &lt;li id="li_5" &gt;
              &lt;label class="description" for="element_5" name="origin" &gt;Origin &lt;/label&gt;
              &lt;input type="text" name="origin" /&gt;
          &lt;/li&gt;
          &lt;li id="li_6" &gt;
              &lt;label class="description" for="element_6" name="destination" &gt;Destination &lt;/label&gt;
              &lt;input type="text" name="destination" /&gt;
          &lt;/li&gt;
          &lt;li id="li_7" &gt;
              &lt;label class="description" for="element_7" name="header" &gt;Header &lt;/label&gt;
              &lt;input type="text" name="header" /&gt;
          &lt;/li&gt;
          &lt;li id="li_8" &gt;
              &lt;label class="description" for="element_8" name="content" &gt;Content &lt;/label&gt;            &lt;textarea rows="15" cols="40" name="content"&gt;&lt;/textarea&gt;
              &lt;br/&gt;
          &lt;/li&gt;
          &lt;input type="Submit" /&gt;
      &lt;/ul &gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>And anohter PHP that connects to my MySQL:</p>
  
  <pre><code>&lt;?php
  
      $id = $_POST['element_1'];
      $date = $_POST['element_3_3'].'-'.$_POST['element_3_1'].'-'.$_POST['element_3_2'];
      $refid = $_POST['element_2'];
      $classification = $_POST['element_4'];
      $origin = $_POST['element_5'];
      $destination = $_POST['element_6'];
      $header = $_POST['element_7'];
      $content = $_POST['element_8']; 
  
      $con = mysql_connect("localhost","XXXXXX","XXXXXX");
      if (!$con)
      {
          die('Error connecting to mysql server:  ' . mysql_error());
      }
  
      mysql_select_db("XXXXXX", $con);
  
      $sql="INSERT INTO emails (id, date, refid, classification, origin, destination, header, content)
      VALUES
      ('$_POST[id]','$_POST[date]','$_POST[refid]','$_POST[classification]','$_POST[origin]','$_POST[destination]','$_POST[header]','$_POST[content]')";
  
      if (!mysql_query($sql,$con))
      {
          die('Error: ' . mysql_error());
      }
      echo "1 record added";
  
      mysql_close($con);
  ?&gt;
  </code></pre>
  
  <p>All other forms are working and I can add them, all except Date. Maybe because I add DAY / MONTH / YEAR as one string on wrong way.</p>