l106/H11/11.9.php
<!DOCTYPE html>
<html lang="en">
<head>
<?php
$naam = $_POST['naam'];
$wachtwoord = $_POST['wachtwoord'];
setcookie('naam', $naam, time() + 52*7*24*60*60);
setcookie('wachtwoord', $wachtwoord, time() +52*7*24*60*60);
if(isset($_POST['username']) && isset($_POST['password'])){
$username = $_POST['username'];
$password = $_POST['password'];
}
?>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<form method='post' action =''>
<div>Username <input type='text' name='username' value=""></div>
<div>Password <input type='password' name='password' value=""></div>
<div><input type='submit' value='Aanmelden'></div>
</form>
<?php
if(isset($_POST['username']) && isset($_POST['password'])){
if($username == $_COOKIE['naam'] && $password == $_COOKIE['wachtwoord']){
echo "je bent ingelogt";
}
else{
echo "de gegevens zijn fout";
}
}
?>
</body>
</html>
Resultaat
Made by Thijs Aarnoudse