first commit

This commit is contained in:
No4m
2025-10-27 20:35:12 +01:00
commit 9187f41e17
19 changed files with 504 additions and 0 deletions

31
include/authenticator.php Normal file
View File

@@ -0,0 +1,31 @@
<?php
session_start();
function isLogged(): bool
{
return isset($_SESSION['user']);
}
function checkLogin(PDO $pdo, $login, $password): bool
{
$stmt = $pdo->prepare('SELECT * FROM utilisateur WHERE login = ?');
$stmt->execute([$login]);
$user = $stmt->fetch();
if ($user && password_verify($password, $user['password'])) {
$_SESSION['user'] = $user['login'];
return true;
}
return false;
}
function requireLogin() {
if (!isLogged()) {
header('Location: login.php');
exit;
}
}