Files
cms-simplifie-kilian-terki/admin/connexion.php

42 lines
1.1 KiB
PHP

<?php
session_start();
require '../includes/db.php';
$message = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$login = trim($_POST['login']);
$password = trim($_POST['password']);
$stmt = $pdo->prepare("SELECT * FROM utilisateur WHERE login = ?");
$stmt->execute([$login]);
$user = $stmt->fetch(PDO::FETCH_ASSOC);
if ($user && password_verify($password, $user['password'])) {
$_SESSION['admin'] = $user['login'];
header('Location: tabledebord.php');
exit;
} else {
$message = "Identifiants incorrects";
}
}
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<link rel="stylesheet" href="../style.css">
<meta charset="UTF-8">
<title>Connexion Administrateur</title>
</head>
<body>
<h2>Connexion Administrateur</h2>
<form method="post">
<input type="text" name="login" placeholder="Login" required><br><br>
<input type="password" name="password" placeholder="Mot de passe" required><br><br>
<button type="submit">Se connecter</button>
</form>
<p style="color:red;"><?= htmlentities($message) ?></p>
</body>
</html>