This commit is contained in:
2019-07-04 09:56:06 +02:00
parent 0319dd3b56
commit 921e3cc991
3 changed files with 25 additions and 9 deletions

View File

@@ -34,16 +34,14 @@ class Database
$this->connection->close(); $this->connection->close();
} }
/** public function addQuestion($question, $answer0, $answer1, $answer2, $solution)
* 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)
{ {
$statement = $this->connection->prepare("INSERT INTO tasks(name) VALUES(?)"); $statement = $this->connection->prepare("INSERT INTO questions(question, answer0, answer1, answer2, solution) VALUES(?, ?, ?, ?)");
$statement->bind_param("s", $name); $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(); return $statement->execute();
} }

View File

@@ -54,4 +54,6 @@ echo <<<END
<a href="questions-create.php">Frage hinzufügen</a> <a href="questions-create.php">Frage hinzufügen</a>
END; END;
$db->destroy();
?> ?>

View File

@@ -0,0 +1,16 @@
<?php
require_once(__DIR__ . '/Database.php');
$question = $_POST['question'];
$answer0 = $_POST['answer0'];
$answer1 = $_POST['answer1'];
$answer2 = $_POST['answer2'];
$db = new Database();
db->addQuestion($question, $answer0, $answer1, $answer2, $solution);
db->destroy();
?>