From 6bc1a522a134d6aba60d9af321ee8a136b959ea2 Mon Sep 17 00:00:00 2001 From: structix Date: Thu, 4 Jul 2019 13:35:00 +0200 Subject: [PATCH] Update --- cgi-bin/uebung09/Database.php | 6 +++--- cgi-bin/uebung09/questions-update.php | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cgi-bin/uebung09/Database.php b/cgi-bin/uebung09/Database.php index 81546ed..b4e8028 100644 --- a/cgi-bin/uebung09/Database.php +++ b/cgi-bin/uebung09/Database.php @@ -41,9 +41,9 @@ class Database return $statement->execute(); } - public function updateQuestion($question, $answer0, $answer1, $answer2, $solution) { - $statement = $this->connection->prepare("UPDATE questions SET question=?, answer0 = ?, answer1 = ?, answer2 = ?, solution = ?"); - $statement->bind_param("ssssi", $question, $answer0, $answer1, $answer2, $solution); + public function updateQuestion($id, $question, $answer0, $answer1, $answer2, $solution) { + $statement = $this->connection->prepare("UPDATE questions SET question=?, answer0 = ?, answer1 = ?, answer2 = ?, solution = ? WHERE id = ?"); + $statement->bind_param("ssssii", $question, $answer0, $answer1, $answer2, $solution, $id); return $statement->execute(); } diff --git a/cgi-bin/uebung09/questions-update.php b/cgi-bin/uebung09/questions-update.php index cbce86c..b6393b3 100644 --- a/cgi-bin/uebung09/questions-update.php +++ b/cgi-bin/uebung09/questions-update.php @@ -2,6 +2,7 @@ require_once(__DIR__ . '/Database.php'); +$id = $_POST['id']; $question = $_POST['question']; $answer0 = $_POST['answer0']; $answer1 = $_POST['answer1']; @@ -10,7 +11,7 @@ $solution = $_POST['solution']; $db = new Database(); -$db->updateQuestion($question, $answer0, $answer1, $answer2, $solution); +$db->updateQuestion($id, $question, $answer0, $answer1, $answer2, $solution); //header("Location: questions-show.php");