setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { echo $e->getMessage(); } if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["name"]) && isset($_POST["date"]) && isset($_POST["time"])) { # values will always be set, check if they are empty... echo "Information submitted!
"; echo "Date: " . date('Y-m-d H:i:s') . "
"; echo "User date: " . $_POST["date"] . "
"; echo "User time: " . $_POST["time"] . "
"; //$toDT='2020-10-10 12:00:00'; $toDT=$_POST["date"] . " " . $_POST["time"] . ":00"; echo "$toDT
"; try { $stmt = $conn->prepare("INSERT INTO tbl1 (`name`, `from`, `to`) VALUES (:name, :from, :to)"); $stmt->bindParam(':name', $_POST['name']); $stmt->bindParam(':from', date('Y-m-d H:i:s')); $stmt->bindParam(':to', $toDT); $stmt->execute(); } catch (PDOException $e) { echo $e->getMessage(); } } ?> Test table




\n"; echo "IDFromToNameActions\n"; foreach ($conn->query("SELECT * FROM tbl1 ORDER BY `id` DESC") as $row) { echo "" . $row['id'] . ""; echo "
" . $row['from'] . "
"; echo "
" . $row['to'] . "
"; echo "
" . $row['name'] . "
"; echo ""; echo ""; echo ""; echo ""; echo "\n"; } echo "\n"; } catch (PDOException $e) { echo $e->getMessage(); } ?>