Files
woordjes/login.php
T
2026-06-16 11:25:00 +02:00

104 lines
1.8 KiB
PHP

<?php
require_once 'includes/config.php';
require_once 'includes/jsondb.php';
require_once 'includes/functions.php';
$error = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$username = sanitize($_POST['username']);
$password = $_POST['password'];
$userFile =
userPath($username) .
'/user.json';
if (!file_exists($userFile)) {
$error = 'Onbekende gebruiker';
} else {
$user = JsonDB::read($userFile);
if (
password_verify(
$password,
$user['password']
)
) {
$_SESSION['user'] =
$user['username'];
header('Location: dashboard.php');
exit;
} else {
$error = 'Fout wachtwoord';
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Login</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="theme-color" content="#222">
<link rel="manifest" href="/manifest.json">
<link rel="stylesheet" href="/assets/css/style.css">
<link rel="apple-touch-icon" sizes="180x180" href="/assets/img/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/assets/img/favicon.ico">
<link rel="icon" type="image/png" sizes="16x16" href="/assets/img/favicon-16x16.png">
</head>
<body>
<div class="container">
<div class="card">
<h1>Login</h1>
<?php if ($error): ?>
<p><?= $error ?></p>
<?php endif; ?>
<form method="post">
<input
name="username"
placeholder="Gebruikersnaam"
required>
<input
type="password"
name="password"
placeholder="Wachtwoord"
required>
<button type="submit">
Inloggen
</button>
</form>
<p>
<a href="register.php">
Nieuw account
</a>
</p>
</div>
</div>
</body>
</html>