Hope someone can help me with the folowing.

I have a date in a data table Works perfect to put a date in the table.

But when i delete the date and the update with an empty date it wil update me the date of today.
But i want it empty

<?php
if(isset($_POST['zenden']))
{

    if(empty($_POST['datum_huwelijk']))
    {
                $datum_huwelijk = null; 
    }

    if($_POST['datum_huwelijk'] != "" || $_POST['datum_huwelijk'] != " " || $_POST['datum_huwelijk'] != "  ")
    {
        $datum_huwelijk = new DateTime($_POST['datum_huwelijk']);
        $datum_huwelijk = date_format($datum_huwelijk, 'Y-m-d');
    }
        $con = mysql_connect("localhost","login-name","password");
        if (!$con)
        {
            die('Could not connect: ' . mysql_error());
        }

                        mysql_select_db("stamboom", $con);

                        $updatequeryy = "UPDATE stamboom_dohmen SET  datum_huwelijk='$datum_huwelijk'
                        WHERE id='".$_SESSION['id_te_bewerken_persoon']."'";
                        mysql_query($updatequeryy) or die (mysql_error()); 
}

?>
<form action="" method="post" name="myform" enctype="multipart/form-data">
   <div style="padding:7px; height:12px; width:210px; background-color:#000; color:#FFF; font-size:10px; text-align:right;
       float:left;" >Date:
   </div>
      <input type="text"  readonly="readonly" name="datum_huwelijk" value="<?php 
          if($rowman['datum_huwelijk']=='0000-00-00')
          {
          echo "";
          }
          else
            {
                $dat_huwe = new DateTime($rowman['datum_huwelijk']);
                $dat_huwel = date_format($dat_huwe, 'd-m-Y'); echo $dat_huwel;
                } ?>" size="15" style="font-size:12px; margin-left:3px; float:left;  height:20px;  cursor:pointer;"
                title="DD-MM-YYYY." onClick="javascript:NewCssCal('demo4')" id="demo4">
              <img src="../images/cal.gif" alt="" onClick="javascript:NewCssCal('demo4')" style="cursor:pointer;
                  margin-left:10px; float:left;">&nbsp;&nbsp;&nbsp;
              <input type="button" style="margin-left:10px; float:left;"
              onclick="document.getElementById('demo4').value=''" value="Delete date">

              <input type="submit" style="width:100px;"  name="zenden" value="Alles verzenden"/>
 </form>

When i write

onclick="document.getElementById('demo4').value='0000-00-00'"

It works but not when i write

onclick="document.getElementById('demo4').value=''"

thanks in advice John

Has your table perhaps been created with a default value for your date column?

no the table is alright i set it as date so as i said i can ad new dates and update a new date. but not update it to NULL.

i have found the problem. had a conflict with another piece of javascript.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.