Show sourcecode
The following files exists in this folder. Click to view.
webbserverprogramering/exercises/
phpstartsida.php
uppgiftForm_1.php
uppgiftFunk_1.php
uppgiftFunk_2.php
uppgiftFunk_3.php
uppgiftFunk_4.php
uppgiftFunk_5.php
uppgiftFunk_6.php
uppgiftIncl_1.php
uppgiftIncl_1_incl.php
uppgiftIncl_2_1.php
uppgiftIncl_2_2.php
uppgiftIncl_2_3.php
uppgiftIncl_2_slut.php
uppgiftIncl_2_start.php
uppgiftIncl_2_tal.php
uppgiftQuiz.php
uppgiftString_1.php
uppgiftString_2.php
uppgiftString_3.php
uppgiftString_4.php
uppgiftString_5.php
uppgift_1.php
uppgift_2.php
uppgift_3.php
uppgift_4.php
uppgift_5.php
uppgiftQuiz.php
156 lines UTF-8 Windows (CRLF)
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
<!DOCTYPE html>
<html lang="sv">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<style>
body {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
</style>
<body>
<?php
$f = $_POST["f"] ?? 0;
$f0 = ("lösen123");
$f1 = $_POST["f1"] ?? "";
$f2 = $_POST["f2"] ?? "";
$f3 = $_POST["f3"] ?? "";
$skickad = isset($_POST["skicka"]);
$lösen_sent = $_POST["lösen_sent"] ?? 0;
if (isset($_POST["nasta"])) {
$f++;
}
if ($lösen_sent == 1) {
if ($_POST["lösen"] == $f0) {
$f++;
}
}
$poang = 0;
if (isset($_POST["f1"])) {
$mottaget = ($_POST["f1"]);
if ($mottaget == "b") $poang++;
}
if (isset($_POST["f2"])) {
$mottaget = ($_POST["f2"]);
if ($mottaget == "a") $poang++;
}
if (isset($_POST["f3"])) {
$mottaget = ($_POST["f3"]);
if ($mottaget == "d") $poang++;
}
?>
<h1>Edvins Quiz</h1>
<form action="" method="post">
<?php if ($f == 0) { ?>
<label for="losen">
<h3>Lösenord krävs</h3>
</label>
<input type="text" name="lösen" placeholder="Lösenord">
<?php } ?>
<?php if ($f >= 1) { ?>
<input type="hidden" name="f1"
value="<?php echo htmlspecialchars($f0); ?>">
<?php } ?>
<?php if ($f >= 1) { ?>
<label for="f1">
<h3>Vilken linje bäst</h3>
</label>
<input type="radio" name="f1" value="a"> Sammhälle
<br>
<input type="radio" name="f1" value="b"> Teknik
<br>
<input type="radio" name="f1" value="c"> Ekonomi
<br>
<input type="radio" name="f1" value="d"> Estet
<br>
<?php } ?>
<?php if ($f >= 2) { ?>
<input type="hidden" name="f1"
value="<?php echo htmlspecialchars($f1); ?>">
<?php } ?>
<?php if ($f == 2) { ?>
<label for="f2">
<h3>Vilken boss är svårast i Hollow Knight Silksong</h3>
</label>
<input type="radio" name="f2" value="a"> Sister Splinter
<br>
<input type="radio" name="f2" value="b"> Savage Beastfly
<br>
<input type="radio" name="f2" value="c"> Grand Mother Silk
<br>
<input type="radio" name="f2" value="d"> Last Judge
<br>
<?php } ?>
<?php if ($f >= 3) { ?>
<input type="hidden" name="f2"
value="<?php echo htmlspecialchars($f2); ?>">
<?php } ?>
<?php if ($f == 3) { ?>
<label for="f3">
<h3>?</h3>
</label>
<input type="radio" name="f3" value="a"> JA
<br>
<input type="radio" name="f3" value="b"> NAJ
<br>
<input type="radio" name="f3" value="c"> Kanske
<br>
<input type="radio" name="f3" value="d"> Vet inte?
<br>
<?php } ?>
<?php if ($f >= 4) { ?>
<input type="hidden" name="f3"
value="<?php echo htmlspecialchars($f3); ?>">
<?php } ?>
<?php if ($f == 0) { ?>
<button type="submit" name="lösen_sent" value="1">Logga in</button>
<?php } elseif ($f < 3) { ?>
<input type="hidden" name="f"
value="<?php echo $f; ?>">
<input type="submit" name="nasta" value="Nästa">
<?php } elseif ($f == 3) { ?>
<input type="hidden" name="f" value="4">
<input type="submit" name="skicka" value="Skicka in">
<?php } ?>
</form>
<?php
if ($skickad) {
echo "<h1>" . $poang . " poäng av 3 möjliga </h1>";
$mejlhuvud = "From: edvnor25@varmdogymnasium.se \nReply-To: kalle@anka.se";
mail("edvnor25@varmdogymnasium.se", "Quiz savr", $poang, $mejlhuvud);
}
?>
</body>
</html>