From 921e3cc9916897d33d3f1c89983a844add1039ce Mon Sep 17 00:00:00 2001 From: structix Date: Thu, 4 Jul 2019 09:56:06 +0200 Subject: [PATCH] Update --- cgi-bin/uebung09/Database.php | 16 +++++++--------- cgi-bin/uebung09/questions-show.php | 2 ++ cgi-bin/uebung09/questions-store.php | 16 ++++++++++++++++ 3 files changed, 25 insertions(+), 9 deletions(-) create mode 100644 cgi-bin/uebung09/questions-store.php diff --git a/cgi-bin/uebung09/Database.php b/cgi-bin/uebung09/Database.php index 97b9c42..279b1b7 100644 --- a/cgi-bin/uebung09/Database.php +++ b/cgi-bin/uebung09/Database.php @@ -34,16 +34,14 @@ class Database $this->connection->close(); } - /** - * Fügt einen Task mit dem Namen $name in die Tabelle tasks ein - * - * @param string $name - * @return bool true, falls Einfügen erfolgreich - */ - public function addTask($name) + public function addQuestion($question, $answer0, $answer1, $answer2, $solution) { - $statement = $this->connection->prepare("INSERT INTO tasks(name) VALUES(?)"); - $statement->bind_param("s", $name); + $statement = $this->connection->prepare("INSERT INTO questions(question, answer0, answer1, answer2, solution) VALUES(?, ?, ?, ?)"); + $statement->bind_param("s", $question); + $statement->bind_param("s", $answer0); + $statement->bind_param("s", $answer1); + $statement->bind_param("s", $answer2); + $statement->bind_param("i", $solution); return $statement->execute(); } diff --git a/cgi-bin/uebung09/questions-show.php b/cgi-bin/uebung09/questions-show.php index 4bc8a8a..4a6fa8d 100644 --- a/cgi-bin/uebung09/questions-show.php +++ b/cgi-bin/uebung09/questions-show.php @@ -54,4 +54,6 @@ echo <<Frage hinzufügen END; +$db->destroy(); + ?> diff --git a/cgi-bin/uebung09/questions-store.php b/cgi-bin/uebung09/questions-store.php new file mode 100644 index 0000000..75c5fce --- /dev/null +++ b/cgi-bin/uebung09/questions-store.php @@ -0,0 +1,16 @@ +addQuestion($question, $answer0, $answer1, $answer2, $solution); + +db->destroy(); + +?>