我如何发布日期输入的内容?

i have a form in html that contains an input type=date, and a php code to post the informations in a database,

php:

if(isset($_POST['Ajouter'])){ // Fetching variables of the form which 
travels in URL
$date = $_POST['date'];



$requete="insert into absences(IdAbs, DateAbs, IdEmp ) values ('1', '$date', 
  '3')";
$query = mysqli_query($db,$requete);

html :

<!Doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body> 
<form action="testabs.php" method="post">
<input id="date" type="date" name="date"> 
<input type="Submit" value="Ajouter" name="Ajouter">*
</form>
</body>
</html>

i don't know how to post the type=date, can anyone help me with this?

If you are getting an undefined index it probably means the date isn't being posted. Try:

if(isset($_POST['date']))
{
    $date= $_POST['date'];
}
else
{
    $date= "2020-02-02";
}

Or if using PHP7+

$date= (isset($_POST['date']) ? $_POST['date'] : "2020-02-02");

If you end up with 2020-02-02 in your database, you have a post issue.

To change the format to suit SQL date field:

$inputDate= new dateTime($_POST['date']);
$date= $inputDate->format('Y-m-d');

You still need to add a suitable check to see if the date actually exists in the first place.