Hi everyone,
My table ("list") contains one field ("exam_date") type: "datetime".
I want users to insert, via a Form, a value of datetime type so i can insert it into that table.
I want to display a default value in the input field: present date& time.
My code goes like this:
The above code doesn't show present date & time !
It adds a new row to my table but a blank date value ! no date added !
Can anyone show me the mistake i made in that code?
Thanks !
My table ("list") contains one field ("exam_date") type: "datetime".
I want users to insert, via a Form, a value of datetime type so i can insert it into that table.
I want to display a default value in the input field: present date& time.
My code goes like this:
Code:
<!doctype html>
<html lang=en>
<head>
<title>Show Date</title>
<meta charset=utf-8>
</head>
<body>
<?php
$dbcon = @mysqli_connect ('xxx', 'xxx', 'xxx', 'xxx')
OR die ('Could not connect to MySQL: ' . mysqli_connect_error () );
mysqli_set_charset($dbcon, 'utf8');
if (isset($_POST['exam_date']))
{
$myDate = trim($_POST['exam_date']);
$q = "INSERT INTO list (exam_date) VALUES ($myDate)";
$result = @mysqli_query ($dbcon, $q);
?>
<form action="to_forum.php" method="post">
<input id="exam_date" name="exam_date" type="datetime"
value="<?php echo date(); ?>">
<input id="submit" type="submit" name="submit" value="Send">
</form>
</body>
</html>]
It adds a new row to my table but a blank date value ! no date added !
Can anyone show me the mistake i made in that code?
Thanks !