Show sourcecode
The following files exists in this folder. Click to view.
cookies.php
formular.php
fragetest3.php
funktioner.php
grunder.php
include/
klasser.php
ovn_cookies1.php
ovn_cookies2.php
ovn_form1.php
ovn_form2.php
ovn_form3.php
ovn_form4.php
ovn_form6.php
ovn_funk1.php
ovn_funk2.php
ovn_funk3.php
ovn_funk4.php
ovn_funk5.php
ovn_grn1.php
ovn_grn2.php
ovn_grn3a.php
ovn_grn3b.php
ovn_include1.php
ovn_klasser1.php
ovn_string1.php
ovn_string2.php
ovn_string3.php
ovn_stringsvar1.php
ovn_stringsvar2.php
ovn_stringsvar3.php
sida1.php
string.php
fragetest3.php
93 lines UTF-8 Windows (CRLF)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<!DOCTYPE html>
<html>
<body>
<h1>Peters Quiz</h1>
<form method="post" action="">
<?php
session_start();
if (!isset($_SESSION['name'])) {
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["namn"])) {
$_SESSION['name'] = $_POST["namn"];
} else {
?>
Namn: <input type="text" name="namn" required><br>
<input type="submit" value="Starta Quiz">
<?php
exit;
}
}
?>
<?php
if (!isset($_POST['currentQuestion'])) {
$currentQuestion = 1;
$_SESSION['score'] = 0;
} else {
$currentQuestion = $_POST['currentQuestion'];
}
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["answer"])) {
$correctAnswers = [
"bench" => "q1a2",
"matkort" => "q2a4",
"SD" => "q3a2"
];
if ($currentQuestion == 1 && $_POST["answer"] == $correctAnswers["bench"]) {
$_SESSION['score']++;
} elseif ($currentQuestion == 2 && $_POST["answer"] == $correctAnswers["matkort"]) {
$_SESSION['score']++;
} elseif ($currentQuestion == 3 && $_POST["answer"] == $correctAnswers["SD"]) {
$_SESSION['score']++;
}
$currentQuestion++;
}
if ($currentQuestion == 1) {
?>
<h3>Fråga 1: Vad maxar jag i bänkpress?</h3>
<input type="radio" name="answer" value="q1a1"><label for="q1a1">105 kg</label><br>
<input type="radio" name="answer" value="q1a2"><label for="q1a2">97,5 kg</label><br>
<input type="radio" name="answer" value="q1a3"><label for="q1a3">90 kg</label><br>
<input type="radio" name="answer" value="q1a4"><label for="q1a4">80 kg 😂</label><br>
<input type="hidden" name="currentQuestion" value="1">
<?php
} elseif ($currentQuestion == 2) {
?>
<h3>Fråga 2: Vilket är det bästa stället på matkortet, om man prioriterar kvalitet?</h3>
<input type="radio" name="answer" value="q2a1"><label for="q2a1">Hemköp</label><br>
<input type="radio" name="answer" value="q2a2"><label for="q2a2">Bastard Burgers</label><br>
<input type="radio" name="answer" value="q2a3"><label for="q2a3">Subway</label><br>
<input type="radio" name="answer" value="q2a4"><label for="q2a4">Bamses Pizzeria</label><br>
<input type="hidden" name="currentQuestion" value="2">
<?php
} elseif ($currentQuestion == 3) {
?>
<h3>Fråga 3: Vem är partiledare för Sverigedemokraterna?</h3>
<input type="radio" name="answer" value="q3a1"><label for="q3a1">Leif GW Persson</label><br>
<input type="radio" name="answer" value="q3a2"><label for="q3a2">Jimmie Åkesson</label><br>
<input type="radio" name="answer" value="q3a3"><label for="q3a3">Ronald Reagan</label><br>
<input type="radio" name="answer" value="q3a4"><label for="q3a4">Carl Bildt</label><br><br>
<input type="hidden" name="currentQuestion" value="3">
<?php
} elseif ($currentQuestion == 4) {
echo "<h2>" . $_SESSION['name'] . ", du fick " . $_SESSION['score'] . " av 3 rätt!</h2>";
session_destroy();
}
?>
<input type="submit" value="Skicka">
</form>
</body>
</html>