Show sourcecode
The following files exists in this folder. Click to view.
ovn_fr.php
ovn_funk.php
ovn_gr_1-5.php
style/
ovn_fr.php
196 lines UTF-8 Windows (CRLF)
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
<?php
$title = "Formulär";
$Rattlosen = "2gh13js";
$email = "valwah25@varmdogymnasium.se";
$namn = trim($_POST["skickat"] ?? "");
$losen = $_POST["lösen"] ?? "";
?>
<!DOCTYPE html>
<html lang="sv">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php echo htmlspecialchars($title); ?></title>
</head>
<body>
<h1>Formulär</h1>
<?php
if (isset($_POST["skicka_resultat"])) {
$frag1 = $_POST["frag1"] ?? "";
$frag2 = $_POST["frag2"] ?? "";
$frag3 = $_POST["frag3"] ?? "";
$score = 0;
if ($frag1 == "5") {
$score++;
}
if ($frag2 == "56") {
$score++;
}
if ($frag3 == "25") {
$score++;
}
$subject = "Resultat från formuläret";
$message = "Namn: " . htmlspecialchars($namn) . "\n\nPoäng: $score av 3\n\nSvar:\nFrag1=$frag1\nFrag2=$frag2\nFrag3=$frag3";
$headers = "From: formulär@exempel.se";
mail($email, $subject, $message, $headers);
if (mail($email, $subject, $message, $headers)) {
echo "Resultatet har skickats till $email.";
} else {
echo "Ett fel uppstod vid skickandet av resultatet.";
}
} else {
if ($namn !== "" && $losen !== $Rattlosen) {
echo "<p style='color: red;'>Fel lösenord. Försök igen.</p>";
}
if ($namn === "" || $losen !== $Rattlosen) {
?>
<form method="post" action="">
<label for="skickat">Skriv ditt namn:</label><br>
<input type="text" name="skickat" required>
<br><br>
<label for="lösen">Lösenord:</label><br>
<input type="password" name="lösen" required>
<br><br>
<input type="submit" value="Skicka">
</form>
<?php
} elseif (!isset($_POST["frag1"])) {
echo "Du heter " . htmlspecialchars($namn) . "<br><br>";
?>
<form method="post" action="">
<input type="hidden" name="skickat" value="<?php echo htmlspecialchars($namn); ?>">
<input type="hidden" name="lösen" value="<?php echo htmlspecialchars($losen); ?>">
<label for="frag1">Vad är 3 + 2?</label><br>
<input type="radio" name="frag1" value="5" required>
<label for="frag1">5</label><br>
<input type="radio" name="frag1" value="6">
<label for="frag1">6</label><br>
<input type="radio" name="frag1" value="7">
<label for="frag1">7</label><br>
<input type="radio" name="frag1" value="8">
<label for="frag1">8</label><br><br>
<input type="submit" value="Nästa">
</form>
<?php
} elseif (!isset($_POST["frag2"])) {
echo "Du heter " . htmlspecialchars($_POST["skickat"]) . "<br><br>";
?>
<form method="post" action="">
<input type="hidden" name="skickat" value="<?php echo htmlspecialchars($_POST["skickat"]); ?>">
<input type="hidden" name="lösen" value="<?php echo htmlspecialchars($_POST["lösen"]); ?>">
<input type="hidden" name="frag1" value="<?php echo htmlspecialchars($_POST["frag1"]); ?>">
<label for="frag2">Vad är 7 * 8?</label><br>
<input type="radio" name="frag2" value="56" required>
<label for="frag2">56</label><br>
<input type="radio" name="frag2" value="64">
<label for="frag2">64</label><br>
<input type="radio" name="frag2" value="49">
<label for="frag2">49</label><br>
<input type="radio" name="frag2" value="72">
<label for="frag2">72</label><br><br>
<input type="submit" value="Nästa">
</form>
<?php
} elseif (!isset($_POST["frag3"])) {
echo "Du heter " . htmlspecialchars($_POST["skickat"]) . "<br><br>";
?>
<form method="post" action="">
<input type="hidden" name="skickat" value="<?php echo htmlspecialchars($_POST["skickat"]); ?>">
<input type="hidden" name="lösen" value="<?php echo htmlspecialchars($_POST["lösen"]); ?>">
<input type="hidden" name="frag1" value="<?php echo htmlspecialchars($_POST["frag1"]); ?>">
<input type="hidden" name="frag2" value="<?php echo htmlspecialchars($_POST["frag2"]); ?>">
<label for="frag3">Vad är 5 ^ 2?</label><br>
<input type="radio" name="frag3" value="25" required>
<label for="frag3">25</label><br>
<input type="radio" name="frag3" value="30">
<label for="frag3">30</label><br>
<input type="radio" name="frag3" value="20">
<label for="frag3">20</label><br>
<input type="radio" name="frag3" value="35">
<label for="frag3">35</label><br><br>
<input type="submit" value="Skicka">
</form>
<?php
} else {
$frag1 = $_POST["frag1"];
$frag2 = $_POST["frag2"];
$frag3 = $_POST["frag3"];
$score = 0;
if ($frag1 == "5") {
$score++;
}
if ($frag2 == "56") {
$score++;
}
if ($frag3 == "25") {
$score++;
}
echo "<h2>Resultat</h2>";
echo "<p>Du heter " . htmlspecialchars($_POST["skickat"]) . " och fick $score av 3 rätt.</p>";
?>
<form action="">
<label for="frag1">Vad är 3 + 2?</label><br>
<input type="radio" name="frag1" value="5" disabled <?php if ($frag1 == "5") echo "checked"; ?>>
<label for="frag1" style="color: green;">5</label><br>
<input type="radio" name="frag1" value="6" disabled <?php if ($frag1 == "6") echo "checked"; ?>>
<label for="frag1" <?php if ($frag1 == "6") echo 'style="color: red;"'; ?>>6</label><br>
<input type="radio" name="frag1" value="7" disabled <?php if ($frag1 == "7") echo "checked"; ?>>
<label for="frag1" <?php if ($frag1 == "7") echo 'style="color: red;"'; ?>>7</label><br>
<input type="radio" name="frag1" value="8" disabled <?php if ($frag1 == "8") echo "checked"; ?>>
<label for="frag1" <?php if ($frag1 == "8") echo 'style="color: red;"'; ?>>8</label><br><br>
<br>
<label for="frag2">Vad är 7 * 8?</label><br>
<input type="radio" name="frag2" value="56" disabled <?php if ($frag2 == "56") echo "checked"; ?>>
<label for="frag2" style="color: green;">56</label><br>
<input type="radio" name="frag2" value="64" disabled <?php if ($frag2 == "64") echo "checked"; ?>>
<label for="frag2" <?php if ($frag2 == "64") echo 'style="color: red;"'; ?>>64</label><br>
<input type="radio" name="frag2" value="49" disabled <?php if ($frag2 == "49") echo "checked"; ?>>
<label for="frag2" <?php if ($frag2 == "49") echo 'style="color: red;"'; ?>>49</label><br>
<input type="radio" name="frag2" value="72" disabled <?php if ($frag2 == "72") echo "checked"; ?>>
<label for="frag2" <?php if ($frag2 == "72") echo 'style="color: red;"'; ?>>72</label><br><br>
<br>
<label for="frag3">Vad är 7 * 8?</label><br>
<input type="radio" name="frag3" value="25" disabled <?php if ($frag3 == "25") echo "checked"; ?>>
<label for="frag3" style="color: green;">25</label><br>
<input type="radio" name="frag3" value="30" disabled <?php if ($frag3 == "30") echo "checked"; ?>>
<label for="frag3" <?php if ($frag3 == "30") echo 'style="color: red;"'; ?>>30</label><br>
<input type="radio" name="frag3" value="20" disabled <?php if ($frag3 == "20") echo "checked"; ?>>
<label for="frag3" <?php if ($frag3 == "20") echo 'style="color: red;"'; ?>>20</label><br>
<input type="radio" name="frag3" value="72" disabled <?php if ($frag3 == "72") echo "checked"; ?>>
<label for="frag3" <?php if ($frag3 == "72") echo 'style="color: red;"'; ?>>72</label><br><br>
</form>
<?php
?>
<br>
<form method="post" action="">
<input type="hidden" name="skickat" value="<?php echo htmlspecialchars($_POST["skickat"] ?? ""); ?>">
<input type="hidden" name="lösen" value="<?php echo htmlspecialchars($_POST["lösen"] ?? ""); ?>">
<input type="hidden" name="frag1" value="<?php echo htmlspecialchars($_POST["frag1"] ?? ""); ?>">
<input type="hidden" name="frag2" value="<?php echo htmlspecialchars($_POST["frag2"] ?? ""); ?>">
<input type="hidden" name="frag3" value="<?php echo htmlspecialchars($_POST["frag3"] ?? ""); ?>">
<input type="hidden" name="skicka_resultat" value="1">
<input type="submit" value="Skicka resultat">
</form>
<?php
}
}
?>
</body>
</html>