Show sourcecode
The following files exists in this folder. Click to view.
hej.php
hej.py
index.php
mysqlintro_1.php
ovn_cookie1.php
ovn_cookie2.php
ovn_cookie3_1.php
ovn_cookie3_2.php
ovn_cookie4.php
ovn_cookie5.php
ovn_cookie6.php
ovn_form1.php
ovn_form2.php
ovn_form3_1.php
ovn_form3_2.php
ovn_form7_1.php
ovn_form7_2.php
ovn_form8_1.php
ovn_form_tillamp1_1.php
ovn_form_tillamp1_2.php
ovn_form_tillamp2.php
ovn_form_tillamp3.php
ovn_form_tillamp4.php
ovn_form_tillamp5.php
ovn_form_tillamp6.php
ovn_funk1.php
ovn_funk2.php
ovn_funk3.php
ovn_funk4.php
ovn_funk5.php
ovn_funk6.php
ovn_funk7.php
ovn_funk8.php
ovn_funk9.php
ovn_gr1.php
ovn_gr2.php
ovn_gr3.php
ovn_gr4.php
ovn_gr5.php
ovn_gr6.php
ovn_gr7.php
ovn_incl1/
ovn_incl2/
ovn_incl3/
ovn_klass1.php
ovn_klass2.php
ovn_klass3.php
ovn_klass4.php
ovn_klass5.php
ovn_klass6.php
ovn_klass7.php
ovn_mysqlintro1_1.php
ovn_mysqlintro1_2.php
ovn_str1_1.php
ovn_str1_2.php
ovn_str2_1.php
ovn_str2_2.php
ovn_str3_1.php
ovn_str3_2.php
ovn_str4_1.php
ovn_str4_2.php
ovn_str5_1.php
ovn_str5_2.php
ovn_str6_1.php
ovn_str6_2.php
ovn_form_tillamp4.php
117 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
session_start(); // Starta sessionen högst upp
if (!isset($_SESSION['steg'])) {
$_SESSION['steg'] = 1;
$_SESSION['korrektaSvar'] = 0;
$_SESSION['name'] = '';
$_SESSION['email'] = '';
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if ($_SESSION['steg'] == 1 && isset($_POST['name'])) {
$_SESSION['name'] = $_POST['name'];
$_SESSION['steg'] = 2; // Nästa steg
} elseif ($_SESSION['steg'] == 2 && isset($_POST['fraga1'])) {
if ($_POST['fraga1'] == "2") {
$_SESSION['korrektaSvar']++;
}
$_SESSION['steg'] = 3; // Nästa steg
} elseif ($_SESSION['steg'] == 3 && isset($_POST['fraga2'])) {
if ($_POST['fraga2'] == "3") {
$_SESSION['korrektaSvar']++;
}
$_SESSION['steg'] = 4; // Nästa steg
} elseif ($_SESSION['steg'] == 4 && isset($_POST['fraga3'])) {
if ($_POST['fraga3'] == "4") {
$_SESSION['korrektaSvar']++;
}
$_SESSION['steg'] = 5; // Sista steg
} elseif ($_SESSION['steg'] == 5 && isset($_POST['email'])) {
$_SESSION['email'] = $_POST['email'];
// Skicka e-post
$to = $_SESSION['email'];
$subject = "Dina resultat från frågetävlingen";
$message = "Hej " . $_SESSION['name'] . ",\n\n" .
"Du fick " . $_SESSION['korrektaSvar'] . " av 3 rätt.\n\n" .
"Tack för att du deltog!";
$headers = "From: filipfg@varmdogymnasium.se"; // Byt till en giltig avsändare
mail($to, $subject, $message, $headers);
// Återställ sessionen för att börja om
session_destroy();
header("Location: " . $_SERVER['PHP_SELF']);
exit;
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Frågetävling</title>
</head>
<body>
<?php
if ($_SESSION['steg'] == 1) {
// Formulär för namn
echo '<form action="" method="POST">
<h2>Vad är ditt namn?</h2>
<input type="text" name="name" required>
<button type="submit">Nästa</button>
</form>';
} elseif ($_SESSION['steg'] == 2) {
// Fråga 1
echo '<form action="" method="POST">
<h2>Vad är 1+1?</h2>
<select name="fraga1">
<option value="1">1</option>
<option value="2">2</option> <!-- Rätt svar -->
<option value="3">3</option>
<option value="4">4</option>
</select>
<button type="submit">Nästa</button>
</form>';
} elseif ($_SESSION['steg'] == 3) {
// Fråga 2
echo '<form action="" method="POST">
<h2>Vad är 1+2?</h2>
<select name="fraga2">
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<button type="submit">Nästa</button>
</form>';
} elseif ($_SESSION['steg'] == 4) {
// Fråga 3
echo '<form action="" method="POST">
<h2>Vad är 1+3?</h2>
<select name="fraga3">
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
</select>
<button type="submit">Slutför</button>
</form>';
} elseif ($_SESSION['steg'] == 5) {
echo '<h2>Du fick ' . $_SESSION['korrektaSvar'] . ' av 3 rätt.</h2>';
echo '<form action="" method="POST">
<h2>Ange e-postadress:</h2>
<input type="email" name="email" required>
<button type="submit">Skicka resultat</button>
</form>';
}
?>
</body>
</html>