I have a calendar and i want to insert selected date into mysql database using javascript and php but I'm getting 0000-00-00 in my database row
function monthClick(e) {
clickedDays += 1;
$(e).toggleClass("clicked");
startDateIndex = parseInt($(e).attr('id').split('-')[1]);
startDate = new Date(currentYear, currentMonth, startDateIndex);
id = 160;
var urlU = "id=" + id + "&dateC=" + startDate;
$.ajax({
url : "http://localhost/dateC.php",
type : "GET",
cache : false,
data : urlU,
success : function(response) {
alert(response);
}
});
}
and here is my php file :
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "database";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
$id=$_GET['id'];
$dateDebutC=$_GET['dateDebutC'];
// Check connection²M
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "UPDATE normal SET dateC ='$dateC' WHERE id='$id'";
if ($conn->query($sql)) {
echo 'DB Update successful';
}
else {
echo 'DB Update failed';
}
$conn->close();
?>