Files
intecsync/cgi-bin/uebung09/questions-edit.php
2019-07-07 23:23:17 +02:00

78 lines
2.1 KiB
PHP

<?php
require_once(__DIR__ . '/Database.php');
$id = $_GET['id'];
$db = new Database();
$question = $db->getQuestion($id);
$sol = $question['solution'];
$qu = $question['question'];
$an0 = $question['answer0'];
$an1 = $question['answer1'];
$an2 = $question['answer2'];
echo <<<END
<link rel="stylesheet" href="style.css">
<h1>Frage bearbeiten</h1><form action="questions-update.php" method="post">
<input type="hidden" name="id" value="$id">
<label for="question">Frage:</label> <br>
<textarea name="question" id="question">$qu</textarea> <br><br>
<label for="answer0">Antwort 0:</label>
<div class="form-box">
END;
if ($sol == 0) {
//checked
echo('<input class="form-solution" type="radio" name="solution" value="0" required checked >');
} else {
//unchecked
echo('<input class="form-solution" type="radio" name="solution" value="0" required >');
}
echo <<<END
<input class="form-answer" type="text" name="answer0" id="answer0" required value="$an0">
</div>
<label for="answer1">Antwort 1:</label>
<div class="form-box">
END;
if ($sol == 1) {
//checked
echo('<input class="form-solution" type="radio" name="solution" value="1" required checked >');
} else {
//unchecked
echo('<input class="form-solution" type="radio" name="solution" value="1" required >');
}
echo <<<END
<input class="form-answer"type="text" name="answer1" id="answer1" value="$an1">
</div>
<label for="answer2">Antwort 2:</label>
<div class="form-box">
END;
if ($sol == 2) {
//checked
echo('<input class="form-solution" type="radio" name="solution" value="2" required checked >');
} else {
//unchecked
echo('<input class="form-solution" type="radio" name="solution" value="2" required >');
}
echo <<<END
<input class="form-answer" type="text" name="answer2" id="answer2" value="$an2">
</div>
<button>Frage aktualisieren</button>
</form>
END;
?>