Show sourcecode
The following files exists in this folder. Click to view.
webbserverprogrammering/exercises/repetition/
ovning_1.php
ovning_2.php
ovning_3a.php
ovning_3b.php
ovning_3c.php
ovning_4.php
ovning_5.php
ovning_6.php
ovning_7.php
ovning_7.php
51 lines UTF-8 Windows (CRLF)
<?php
session_start();
!isset($_SESSION["tries"]) && $_SESSION["tries"] = 0;
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/dark.css">
<title>Övning 7</title>
</head>
<body>
<?php
$correct_password = "Tobias!";
if (!isset($_POST["password"])) {
?>
<form method="post">
<label for="name">Ditt namn</label>
<input id="name" name="name" type="name" placeholder="Ange ditt namn">
<label for="email">Din epost</label>
<input id="email" name="email" type="email" placeholder="Ange din epost">
<label for="password">Lösenordet är "Tobias!"</label>
<input id="password" name="password" type="password" placeholder="Ange Lösenordet">
<button type="submit">Skicka</button>
</form>
<?php
} else {
if ($_POST["password"] === $correct_password) {
?>
<h2>Bra jobbat du gav rätt lösenord!</h2>
<p>Nu får du veta en hemlighet: <strong>Benjamin Saleem Brodin petar i näsan!</strong></p>
<?php
} else {
$_SESSION["tries"] += 1;
if ($_SESSION["tries"] >= 3) {
?>
<h2>Sorry du får inte komma in</h2>
<?php
} else {
echo "Fel lösenord. ".(3-$_SESSION["tries"])." försök kvar";
}
}
}
?>
</body>
</html>