first commit
This commit is contained in:
47
admin/login.php
Normal file
47
admin/login.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
require '../includes/db.php';
|
||||
|
||||
if (isset($_POST['login']) && isset($_POST['password'])) {
|
||||
$login = $_POST['login'];
|
||||
$password = $_POST['password'];
|
||||
|
||||
$sql = "SELECT * FROM utilisateur WHERE login = :login";
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->bindParam(':login', $login);
|
||||
$stmt->execute();
|
||||
$user = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($user && password_verify($password, $user['password'])) {
|
||||
$_SESSION['user_id'] = $user['id'];
|
||||
$_SESSION['user_login'] = $user['login'];
|
||||
header('Location: dashboard.php');
|
||||
exit;
|
||||
} else {
|
||||
$error = "Identifiants incorrects.";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Connexion Admin</title>
|
||||
<link rel="stylesheet" href="../assets/css/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<h2>Connexion Administration</h2>
|
||||
|
||||
<?php if(isset($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>
|
||||
<button type="submit">Se connecter</button>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user