Show sourcecode
The following files exists in this folder. Click to view.
funktion1.php
test4.php
test5.php
test6.php
test7.php
test6.php
49 lines UTF-8 Windows (CRLF)
<?php
echo "Session start <br/>";
session_start();
if (!isset($_SESSION['s_nummer'])) {
$_SESSION['s_nummer'] = rand(1, 10);
}
if (!isset($_SESSION['forsok'])) {
$_SESSION['forsok'] = 0;
}
echo "s_nummer: ". $_SESSION['s_nummer'] . "<br/>";
echo "forsok: ". $_SESSION['forsok'] . "<br/>";
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<form action="" method="POST">
<input type="number" name="Gissat_Nummer">
<br/>
<input type="submit" value="testa">
</form>
<?php
if (!isset($_POST["Gissat_Nummer"])) {
echo "skriv in ett nummer";
}
else {
$gissat_nummer = $_POST["Gissat_Nummer"];
echo "Gissat nummer: " . $gissat_nummer . " <br/>";
if ($gissat_nummer == $_SESSION["s_nummer"]) {
echo "du gissade rätt";
session_unset();
session_destroy();
}
else {
$_SESSION["forsok"]++;
echo "du gissade fel, kör igen";
}
}
?>
</body>
</html>