<?php
include "db.php";
include "functions.php";
$ingelogd=false;
if ($_POST["gebruikersnaam"]) { //Detecteert of je probeert in te loggen
$ingelogd = inloggen($_POST["gebruikersnaam"], $_POST["wachtwoord"]); //Logt je in
}
if ($_GET["uitloggen"]){ //Bekijkt of je uit probeert te loggen
uitloggen(); //Logt je uit
header("Location: inloggen.php");
}
if (ingelogd()){
$ingelogd = true;
}
?>
<!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>
<link rel="stylesheet" type="text/css" href="style.css">
<?php
include "nav.php";
?>
<div class="content winkel">
<h1>Inloggen</h1>
<div class="producten login">
<?php
if(ingelogd() || $ingelogd) { //Dit laat de webpagina zien als je al ingelogd bent
echo '<h2>Je bent al ingelogd!</h2>';
echo '<div><a href="inloggen.php?uitloggen=true">Uitloggen</a></div>';
}
else { //Laat een form zien als je nog niet ingelogd bent
echo '<form action="" method="POST">
<div><input type="text" placeholder="Gebruikersnaam" name="gebruikersnaam" id="gebruikersnaam"></div>
<div><input type="password" name="wachtwoord" id="wachtwoord" placeholder="Wachtwoord"></div>
<div><input type="submit" name="submit" id="submit" value="Inloggen"></div>
</form>';
}?>
</div>
</div>
</body>
</html>