Hi
I have the following code below for my php form

<script language="javascript" type="text/javascript" src="datetimepicker.js"></script>

<form action="date.php" method="post">
Date: <input type="Text" id="date" maxlength="25" size="25"><a href="javascript:NewCal('demo1','ddmmmyyyy',true,24)"><img src="images/cal.gif" width="16" height="16" border="0" alt="Date"></a>

I am using the following javascript code datepicker code that shows as follows[ATTACH]5427[/ATTACH]

When i enter a date 13-12-2016 click on the submit button and go into mysql database I only get to see 0000-00-00 how to convert my javascript code to a format that mysql accepts

datepicker.jpg

    I think you need a "name" attribute for your input tag, so that you have a $_POST element of that name.

      NogDog;11059033 wrote:

      I think you need a "name" attribute for your input tag, so that you have a $_POST element of that name.

      I would 2nd that.

      Then, if you still have problems, you should [thread=10258167]SSC/SUTC/SUCK/ ... etc.[/thread]

        <?php

        if(isset($_POST['submit'])){

        $con = mysql_connect("localhost","root","");
        if(!$con){
        die("cant connect");
        }
        mysql_select_db("sata",$con);
        $sql= "INSERT INTO date (dmy) VALUES ('{$_POST['date']}}')";

        mysql_query($sql,$con);

        mysql_close($con)

        that was the 1st part of my code

          Thanks ... please use the [noparse]

          [/noparse] tags when posting your code (it's helpful).

          Did you take NogDog's advice and put a NAME attribute in the HTML "input" tag?

          Also, with the code you've shown, there must be a value with the name "submit" set in the POST array in order for your code to process.

          <form action="date.php" method="post">
          Date: <!--note the NAME attribute that has been added to the next tag-->
          <input name="date" type="Text" id="date" maxlength="25" size="25">
          <a href="javascript:NewCal('demo1','ddmmmyyyy',true,24)"><img src="images/cal.gif" width="16" height="16" border="0" alt="Date"></a>
          
          <!--You also need a "submit"-->
          <input type='submit' name='submit' value="Use This Date">
          </form>
          
          
            Write a Reply...