1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

jquery ui datepicker input not posting to PHP

Discussion in 'jQuery' started by Sn@Ke, Mar 22, 2011.

  1. #1
    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>
    
    HTML:

    EDIT: Will paypal you $10 for correct answer
     
    Last edited: Mar 22, 2011
    Sn@Ke, Mar 22, 2011 IP
  2. Sn@Ke

    Sn@Ke Well-Known Member

    Messages:
    334
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    155
    #2
    job done by crazyryan
     
    Sn@Ke, Mar 22, 2011 IP
  3. anxi0us

    anxi0us Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    $DBirth = $_REQUEST['DBirth'];
    $Date = date('Y-m-d', strtotime($DBirth));


    $employee = "INSERT INTO tablename VALUES('$Date');
     
    anxi0us, Oct 6, 2011 IP