Show sourcecode
The following files exists in this folder. Click to view.
InlämningsFormulär.php
include1.php
include2.php
includesid1.php
includesid2.php
includesid3.php
phpformulär1.php
phpformulär2.php
phpslump6.php
sidslut.php
sidstart.php
test.php
övning1.php
övning2.php
övning3.php
övning4.php
övning5.php
övningfunk1.php
övningfunk2.php
övningfunk3.php
övningfunk4.php
övningfunk5.php
övningfunk6.php
övningtest.php
test.php
206 lines UTF-8 Windows (CRLF)
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
<?php
session_start();
if (isset($_POST["logga_in"])) {
if (($_POST["losenord"] ?? "") === "Wiggo") {
session_regenerate_id(true);
$_SESSION["inloggad"] = true;
} else {
$fel = true;
}
}
if (empty($_SESSION["inloggad"])) {
?>
<!DOCTYPE html>
<html lang="sv">
<head>
<meta charset="UTF-8">
<title>Lösenord</title>
<style>
body {
text-align: center;
font-family: Arial, sans-serif;
}
</style>
</head>
<body>
<h2>Ange lösenord</h2>
<?php if (isset($fel)) { ?>
<p>Fel lösenord!</p>
<?php } ?>
<form method="post">
<input type="password" name="losenord" placeholder="Lösenord" required>
<input type="submit" name="logga_in" value="Logga in">
</form>
</body>
</html>
<?php
exit;
}
$steg = (int)($_POST["steg"] ?? 1);
$namn = $_POST["namn"] ?? "";
$f1 = $_POST["f1"] ?? "";
$f2 = $_POST["f2"] ?? "";
$f3 = $_POST["f3"] ?? "";
$mottagare = "alewel25@varmdogymnasium.se";
if (isset($_POST["nasta"])) {
$steg++;
}
if (isset($_POST["skicka"])) {
$poang = 0;
if ($f1 == "Sverige") $poang++;
if ($f2 == "Evelina") $poang++;
if ($f3 == "Azog the defiler") $poang++;
echo "<h2>Resultat</h2>";
echo "Namn: " . htmlspecialchars($namn, ENT_QUOTES, "UTF-8") . "<br>";
echo "Antal rätt: " . $poang . " av 3";
$rubrik = "Resultat från frågesporten";
$meddelande = "Hej!\n\n";
$meddelande .= "Namn: " . $namn . "\n";
$meddelande .= "Antal rätt: " . $poang . " av 3\n";
$mejlhuvud = "From: alewel25@varmdogymnasium.se\r\n";
$mejlhuvud .= "Content-Type: text/plain; charset=UTF-8\r\n";
if (filter_var($mottagare, FILTER_VALIDATE_EMAIL)) {
if (mail($mottagare, $rubrik, $meddelande, $mejlhuvud)) {
echo "<p>PHP har accepterat mejlet för utskick.</p>";
} else {
echo "<p>Mejlet kunde inte skickas. Kontrollera Laragons mejlinställningar.</p>";
}
} else {
echo "<p>Kontrollera mottagarens mejladress i koden.</p>";
}
} else {
?>
<!DOCTYPE html>
<html lang="sv">
<head>
<meta charset="UTF-8">
<title>Frågesport</title>
<style>
body {
text-align: center;
font-family: Arial, sans-serif;
}
form {
width: 300px;
margin: auto;
}
.alternativ {
text-align: left;
margin-left: 30px;
}
.alternativ label {
display: block;
margin-bottom: 10px;
}
</style>
</head>
<body>
<form method="post">
<?php if ($steg == 1) { ?>
<h2>Vad heter du?</h2>
<input type="text" name="namn" required>
<?php } ?>
<?php if ($steg >= 2) { ?>
<input type="hidden" name="namn"
value="<?= htmlspecialchars($namn, ENT_QUOTES, 'UTF-8') ?>">
<?php } ?>
<?php if ($steg == 2) { ?>
<h2>Vad bor Alexander?</h2>
<div class="alternativ">
<label><input type="radio" name="f1" value="Sverige" required> Sverige</label>
<label><input type="radio" name="f1" value="USA"> USA</label>
<label><input type="radio" name="f1" value="Tyskland"> Tyskland</label>
<label><input type="radio" name="f1" value="Norge"> Norge</label>
</div>
<?php } ?>
<?php if ($steg >= 3) { ?>
<input type="hidden" name="f1"
value="<?= htmlspecialchars($f1, ENT_QUOTES, 'UTF-8') ?>">
<?php } ?>
<?php if ($steg == 3) { ?>
<h2>Vad heter Alexanders syster?</h2>
<div class="alternativ">
<label><input type="radio" name="f2" value="Alice" required> Alice</label>
<label><input type="radio" name="f2" value="Evelina"> Evelina</label>
<label><input type="radio" name="f2" value="Lisa"> Lisa</label>
<label><input type="radio" name="f2" value="Habibi"> Habibi</label>
</div>
<?php } ?>
<?php if ($steg >= 4) { ?>
<input type="hidden" name="f2"
value="<?= htmlspecialchars($f2, ENT_QUOTES, 'UTF-8') ?>">
<?php } ?>
<?php if ($steg == 4) { ?>
<h2>Vad är Wiggo?</h2>
<div class="alternativ">
<label><input type="radio" name="f3" value="En goblin" required> En goblin</label>
<label><input type="radio" name="f3" value="Ett troll"> Ett troll</label>
<label><input type="radio" name="f3" value="Ork"> Ork</label>
<label><input type="radio" name="f3" value="Azog the defiler"> Azog the defiler</label>
</div>
<?php } ?>
<?php if ($steg < 4) { ?>
<input type="hidden" name="steg" value="<?= $steg ?>">
<br><br>
<input type="submit" name="nasta" value="Nästa">
<?php } else { ?>
<input type="hidden" name="steg" value="4">
<br><br>
<input type="submit" name="skicka" value="Skicka in">
<?php } ?>
</form>
</body>
</html>
<?php
}
?>