Update
This commit is contained in:
@@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -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();
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
16
cgi-bin/uebung09/questions-store.php
Normal file
16
cgi-bin/uebung09/questions-store.php
Normal 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();
|
||||||
|
|
||||||
|
?>
|
Reference in New Issue
Block a user