I have looked everywhere, but I can't seem to find the correct code. I have an html form take in a date from the user using the "date" input.
index.html:
<form name="myform" action="process.php" method="POST">
Date: <input type="date" name="date"><br>
<input type="submit" value="Submit">
</form>
Process.php:
$link=mysqli_connect("my.sql.server", "username", "psswd", "database_name")
$date = $_POST['date'];
mysqli_query($link,"INSERT INTO visit_exclude_dates (date) VALUES (CAST $date AS DATE)");
the value of $date when it comes out of the form is in the yyyy-mm-dd format, and I am able to successfully write to the database. My problem is that when I read the database, the date is being shown as 0000-00-00. So I assume that the problem is with this line:
mysqli_query($link,"INSERT INTO visit_exclude_dates (date) VALUES (CAST $date AS DATE)");
EDIT:
I would like to note that visit_exclude_dates is the name of my table
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…