l107/11.9.php
<?php
$usernamecorrect = "sdubbelman";
$passwordcorrect = "hallo";
setcookie('username',$_COOKIE['username'], time() + 0);
setcookie('password',$_COOKIE['password'], time() + 0);
if(($_POST['username']) && ($_POST['password'])&& ($_POST['username'] != "" && $_POST['password'] != "")){
$username = $_POST['username'];
$password = $_POST['password'];
setcookie('username',$_POST['username'], time() + 0);
setcookie('password',$_POST['password'], time() + 0);
}
else{
$username = $_COOKIE['username'];
$password = $_COOKIE['password'];
}
?>
<!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 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' valuea='Aanmelden'></div>
</form>
<?php
if ((($username) && ($password)) && ($username != "" && $password != "")){
if ($username == $usernamecorrect && $password == $passwordcorrect){
echo "Welkom $username";
}
else{
echo "Sorry, geen toegang";
}
}
?>
</body>
</html>
Resultaat
Made by Thijs Aarnoudse