From 83ee4c20beabfc33a0572a053404d6c34319ade9 Mon Sep 17 00:00:00 2001 From: Mateja Date: Thu, 1 Oct 2020 15:50:36 +0200 Subject: DateTime PHP to DB work --- test/index.php | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/index.php b/test/index.php index b0cb731..3b1d7c0 100644 --- a/test/index.php +++ b/test/index.php @@ -1,7 +1,21 @@ You gay!
"; + echo "Information submitted!
"; + echo "Date: " . date('Y-m-d H:i:s') . "
"; + try { + $conn = new PDO("mysql:host=localhost;dbname=testdb", "testuser", "testpass"); + $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $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')); + $toDT='2020-10-10 12:00:00'; + $stmt->bindParam(':to', $toDT); + $stmt->execute(); + } + catch (PDOException $e) { + echo $e->getMessage(); + } } ?> @@ -15,7 +29,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["name"]) && isset($_POS } th, td { border: 1px solid black; - padding: 0.2rem; + padding: 0.3rem; }