2022-06-14 23:36:26 +02:00
|
|
|
<?php
|
|
|
|
$page = "index";
|
|
|
|
include "script.php";
|
|
|
|
if(isset($_POST['login'])) {
|
|
|
|
if (!empty($_POST['pseudo']) and !empty($_POST['password'])) {
|
|
|
|
$pseudo = htmlspecialchars($_POST['pseudo']);
|
|
|
|
$password = htmlspecialchars($_POST['password']);
|
|
|
|
|
|
|
|
$req = $db->prepare("SELECT id, mdp FROM admin WHERE pseudo = ?");
|
|
|
|
$req->execute(array($pseudo));
|
|
|
|
$user_exist = $req->rowcount();
|
|
|
|
if ($user_exist == 1) {
|
|
|
|
while ($user_login = $req->fetch()) {
|
|
|
|
$passwd = $user_login['mdp'];
|
|
|
|
if ((password_verify($password, $passwd)) == 1) {
|
|
|
|
$_SESSION['id'] = $user_login['id'];
|
|
|
|
header('Refresh:0');
|
|
|
|
} else {
|
|
|
|
$error = "Mot de passe invalide !";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$error = "Identifiant invalide !";
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$error = "Tout les champs doivent être complétés";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
|
|
<title>Admin / index</title>
|
|
|
|
</head>
|
|
|
|
<body>
|
2022-06-15 17:35:34 +02:00
|
|
|
<main>
|
2022-06-14 23:36:26 +02:00
|
|
|
<?php
|
|
|
|
if(isset($_SESSION['id'])) {
|
|
|
|
echo "Connecté sous l'identifiant : ".$user['pseudo'];
|
2022-06-15 21:19:49 +02:00
|
|
|
echo "<br><br>Accès : ";
|
|
|
|
switch ($user['perm']) {
|
|
|
|
case 0:
|
|
|
|
echo "<font color='green'>GDA</font>";
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
echo "<font color='orange'>Bureau</font>";
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
echo "<font color='red'>Admin</font>";
|
|
|
|
break;
|
|
|
|
}
|
2022-06-14 23:36:26 +02:00
|
|
|
} else {
|
|
|
|
?>
|
|
|
|
<form method="POST">
|
2022-06-15 21:00:54 +02:00
|
|
|
<input type="text" placeholder="Identifiant" name="pseudo" class="input">
|
|
|
|
<input type="password" placeholder="mot de passe" name="password" class="input">
|
|
|
|
<input type="submit" name="login" value="Se connecter" class="submit">
|
2022-06-14 23:36:26 +02:00
|
|
|
</form>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
if(isset($error)) {
|
|
|
|
echo "<font color='red'>".$error."</font>";
|
|
|
|
}
|
|
|
|
?>
|
2022-06-15 17:35:34 +02:00
|
|
|
</main>
|
2022-06-14 23:36:26 +02:00
|
|
|
</body>
|
|
|
|
</html>
|