jquery ui datepicker input not posting to PHP

jquery ui datepicker input not posting to PHP

I'm having problems posting the selected date from the datepicker. I want to add it into my form so people can simply select a date and it will insert it with the form into the mysql database.

It works fine sometimes... but when other people use it or I try on random machines it will just post "0000-00-00" as the date.

Here is how I'm doing it: (I've trimmed alot of unimportant info from it)

  1. <?PHP
  2. mysql_connect("localhost", "xxx", "xxx") or die(mysql_error());
  3. mysql_select_db("xxx") or die(mysql_error());
  4. if(isset($_POST['submit'])) {

  5. //Prepare all form and check for errors
  6. if(Trim(stripslashes($_POST['jsdate'])) == '') {
  7. $hasError = true;
  8. } else {
  9. $date = $_POST['jsdate'];
  10. }
  11. if(!isset($hasError)) {

  12. //Insert Form into Database 
  13. mysql_query("INSERT INTO table (date, blah, blah) ")
  14. VALUES
  15. ('$date', '$blah', '$blah')
  16. or die(mysql_error());
  17. }
  18. ?>
  19. <html>
  20. <head>
  21. <script type="text/javascript" src="src/jquery-1.4.2.min.js"></script>
  22. <script src="src/jquery.validate.pack.js" type="text/javascript"></script>

  23.  <script type="text/javascript" src="src/jquery-ui-1.8.10.custom.min.js"></script>
  24.  <link type="text/css" href="src/smoothness/jquery-ui-1.8.10.custom.css" rel="stylesheet" />

  25. <script type="text/javascript">
  26. $(document).ready(function(){
  27. $("#assign").validate();
  28. $('#jsdate').datepicker({ dateFormat: 'yy-dd-mm' });
  29. });
  30. </script>
  31. </head>
  32. <body>
  33. <form id="assign" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">

  34. <input type="hidden" name="salesperson" id="salesperson" value="<?php echo "$session->username";?>" />
  35. <tr>
  36. <td>Lead Date:</td>
  37. <td>
  38. <input type="text" class="jsdate" id="jsdate" name="jsdate">
  39. </td>
  40. </tr>
  41. <tr>
  42. <td></td>
  43. <td><input type="submit" name="submit" value="Add Lead"/></td>
  44. </tr>
  45. </form>
  46. </table>
  47. </body>
  48. </html>