How to insert time into database

Hi everybody,

I have a problem with inserting specific time into Mysql database using a form bellow:


<form method="post" action="insert_time.php">
	<input type="time" name="time">
	<input type="submit" value="Insert Time">
</form>

When I input data such as 12:00:00, the value is invalid. How to overcome this problem?

Thanks
Ket

we would need to see the table definition (do a SHOW CREATE TABLE in mysql) as well as the insert_time.php code

thanks for response, here is it:


$mysqli-&gt;query("DROP TABLE IF EXISTS video;") or die("DB error");
$mysqli-&gt;query("CREATE TABLE `video` (
   `vdo_id` INT NOT NULL AUTO_INCREMENT,
   `vdo_path` VARCHAR( 120 ) NOT NULL , 
   `time` TIME NOT NULL  default '00:00:00',
   `title` VARCHAR( 75 ) NOT NULL ,
PRIMARY KEY ( `vdo_id` ) ,
UNIQUE (
   `vdo_path`
   )
 ) ENGINE = INNODB
")
or die("DB error!");

and the insert.php


$title =  trim($_POST['title']);
$time =  trim($_POST['time']);
$vdo_path =  basename($title.$length);

$mysqli-&gt;query("INSERT INTO video(vdo_path, time, title) VALUES('$vdo_path','$time','$title');") or die(mysqli_error());

this does not explain why the time value is not working

could you please echo the php query before executing it

in other words, we need to see the contents of ‘$time’ that mysql sees

I have no idea. It just didn’t work since the <input type=“time” name=“time”>.

The form didn’t pass the value from the input field. The value is blank and it didn’t pass the if(empty($_POST[‘time’]) check.

Additionally, when you use Google chrome it pops up an alert message of ‘Invalid Value’.
Is I use the incorrect form?

A quick search shows the input type “time” to be HTML5, try switching the input type of the form to “text”