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)
- <?PHP
- mysql_connect("localhost", "xxx", "xxx") or die(mysql_error());
- mysql_select_db("xxx") or die(mysql_error());
-
-
- if(isset($_POST['submit'])) {
- //Prepare all form and check for errors
-
- if(Trim(stripslashes($_POST['jsdate'])) == '') {
- $hasError = true;
- } else {
- $date = $_POST['jsdate'];
- }
- if(!isset($hasError)) {
-
- //Insert Form into Database
- mysql_query("INSERT INTO table (date, blah, blah) ")
- VALUES
- ('$date', '$blah', '$blah')
- or die(mysql_error());
-
- }
- ?>
-
- <html>
- <head>
- <script type="text/javascript" src="src/jquery-1.4.2.min.js"></script>
- <script src="src/jquery.validate.pack.js" type="text/javascript"></script>
- <script type="text/javascript" src="src/jquery-ui-1.8.10.custom.min.js"></script>
- <link type="text/css" href="src/smoothness/jquery-ui-1.8.10.custom.css" rel="stylesheet" />
- <script type="text/javascript">
- $(document).ready(function(){
- $("#assign").validate();
- $('#jsdate').datepicker({ dateFormat: 'yy-dd-mm' });
- });
- </script>
- </head>
- <body>
-
-
-
- <form id="assign" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
- <input type="hidden" name="salesperson" id="salesperson" value="<?php echo "$session->username";?>" />
-
- <tr>
- <td>Lead Date:</td>
- <td>
- <input type="text" class="jsdate" id="jsdate" name="jsdate">
- </td>
- </tr>
- <tr>
- <td></td>
- <td><input type="submit" name="submit" value="Add Lead"/></td>
- </tr>
- </form>
- </table>
-
- </body>
- </html>