Refonte complète du projet
This commit is contained in:
34
public/login.php
Normal file
34
public/login.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once '../includes/db.php';
|
||||
require_once '../includes/header.php';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$login = $_POST['login'] ?? '';
|
||||
$password = $_POST['password'] ?? '';
|
||||
|
||||
$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'];
|
||||
header("Location: admin.php");
|
||||
exit;
|
||||
} else {
|
||||
$error = "Identifiants incorrects";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<h2>Connexion administrateur</h2>
|
||||
<?php if (!empty($error)) echo "<p style='color:red;'>$error</p>"; ?>
|
||||
<form method="post">
|
||||
<label>Login :</label><br>
|
||||
<input type="text" name="login" required><br><br>
|
||||
<label>Mot de passe :</label><br>
|
||||
<input type="password" name="password" required><br><br>
|
||||
<input type="submit" value="Se connecter">
|
||||
</form>
|
||||
|
||||
<?php require_once '../includes/footer.php'; ?>
|
||||
Reference in New Issue
Block a user