Premier commit
This commit is contained in:
35
login.php
Normal file
35
login.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once __DIR__ . '/includes/db.php';
|
||||
require_once __DIR__ . '/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: dashboard.php");
|
||||
exit;
|
||||
} else {
|
||||
echo "<p style='color:red;'>Identifiants incorrects</p>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<h2>Connexion administrateur</h2>
|
||||
<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 __DIR__ . '/includes/footer.php'; ?>
|
||||
Reference in New Issue
Block a user