title: Datepicker Date format insert and 0000-00-00
body: <p>I have searched on the above topic and found various answers but didn't help me out
  whenever I post a date on from ny web form, the result on my table is always 0000-00-00
  I have been at this for 2 days and tried all suggestions i found but to no avail. i am sure i'm missing a very tiny detail. here are my codes:</p>
  
  <pre><code>&lt;html&gt;
  
  &lt;head&gt;
  &lt;meta charset="utf-8"&gt;
  &lt;title&gt;IBADAM BMs&lt;/title&gt;
  
  &lt;link rel="stylesheet" href="//code.jquery.com/ui/1.11.3/themes/smoothness/jquery-ui.css"&gt;
  &lt;script src="//code.jquery.com/jquery-1.10.2.js"&gt;&lt;/script&gt;
  &lt;script src="//code.jquery.com/ui/1.11.3/jquery-ui.js"&gt;&lt;/script&gt;
  &lt;link rel="stylesheet" href="/resources/demos/style.css"&gt;
  
  
  &lt;script&gt;
  $(function() {
  $("#datepicker").datepicker({dateFormat: 'yy-mm-dd'});
  });
  &lt;/script&gt;
  
  
  &lt;/head&gt;
  
  &lt;body bgcolor="#E6E6FA"&gt;
  
  &lt;br&gt;
  &lt;div&gt;
      &lt;div style="float: left; margin-left: 340px;&gt;
      &lt;a href="index2.php"&gt;&lt;img src="../image/banner.png" alt="" align=""/&gt;&lt;/a&gt;
  &lt;/div&gt;
  
  &lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;
  
  &lt;div style="float: left; margin-left: 1100px; margin-top: 0px;"&gt;
  &lt;a href="../logout.php"&gt;Log out&lt;/a&gt;
  &lt;/div&gt;
  &lt;br&gt;&lt;br&gt;
  &lt;center&gt;&lt;b&gt;&lt;h3&gt;DIVISION&lt;/h3&gt;&lt;/b&gt;&lt;/center&gt;
  
  &lt;?php
  error_reporting (E_ALL ^ (E_NOTICE + E_WARNING));
  $con=mysqli_connect("localhost","alagbeco","a12345","alagbeco_modem");
  // Check connection
  if (mysqli_connect_errno()) {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
  
  
  if(!isset($_POST['submit'])) {
      ?&gt;
  
  &lt;center&gt;
  &lt;form action="&lt;?php echo $_SERVER['PHP_SELF']?&gt;" method="post"&gt;
  &lt;br&gt;&lt;br&gt;
  
  
  Branch: 
  &lt;select name="branch"&gt;
  &lt;option&gt;&lt;/option&gt;
  &lt;option&gt;DIVINE&lt;/option&gt;
  &lt;option&gt;GLORY 1&lt;/option&gt;
  &lt;option&gt;GLORY 2&lt;/option&gt;
  &lt;/select&gt;
  
  &lt;br&gt;&lt;br&gt;
  
  Date: 
  &lt;input type="text"  name="datepicker" id="datepicker"&gt;
  &lt;br&gt;&lt;br&gt;
  
  
  Amount: 
  &lt;input type="text" name="amount"&gt;
  &lt;br&gt;&lt;br&gt;
  
  &lt;input type="submit" name = "submit" value ="Process"&gt;
  &lt;/form&gt;
  &lt;/center&gt;
  
  
      &lt;?php
  
  
  
  } else {
          // escape variables for security
          $branch = $_POST['branch'];
          $amount = $_POST['amount'];
          $datepicker = $_POST['date'];
  
          //check for existence
          $check_sql = "SELECT count(no) FROM bm_ibadan_division WHERE branch= '$branch' AND date = '$datepicker'";
          $check = mysqli_query($con,$check_sql);
          while ($check_rsult = mysqli_fetch_array($check)) {
              $count = $check_rsult['count(no)'];
              if($count &gt;0 ) {
                  die ("Double treatment not allowed");
              } else {
  
  
  
                      //insert into table
                      $sql = "INSERT INTO bm_ibadan_division (branch, status, amount, date)
                      VALUES ('$branch', 'Reconciled', '$amount', '$datepicker')";
                      $result = mysqli_query($con, $sql);
                  }       echo '&lt;br&gt;&lt;br&gt;&lt;center&gt;Entry Successful&lt;/center&gt;&lt;br&gt;&lt;br&gt;';   
          }   
  }
  
  ?&gt; 
  
  &lt;br&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>