
- /html/upload-file.php - /html/editpage.php - /html/admin.php - /html/journal-interne.php - /html/login.php - /html/compte.php - /html/upload.php - /config/global.ini - /include/variables.php - /include/functions.php
88 lines
2.9 KiB
PHP
88 lines
2.9 KiB
PHP
<?php
|
|
require "../include/variables.php";
|
|
require "../include/functions.php";
|
|
|
|
if(isset($_SESSION['userid'])) {
|
|
header("Location: index.php");
|
|
die("Vous êtes déjà connecté");
|
|
}
|
|
|
|
if(isset($_POST['username']) && isset($_POST['password'])) {
|
|
if(empty($_POST['username']) == false && empty($_POST['password']) === false) {
|
|
$bdd = connect($dbhost, $dbname, $dbuser, $dbpass);
|
|
|
|
$req = $bdd->prepare("SELECT ID, username, email, display_name, role FROM users WHERE (username = :username OR email = :username) AND password = :password");
|
|
$req->bindParam(':username', htmlspecialchars($_POST['username']));
|
|
$req->bindParam(':password', md5($_POST['password']));
|
|
$req->execute();
|
|
|
|
$resultat = $req->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
if ($resultat) {
|
|
$_SESSION['username'] = $resultat[0]['username'];
|
|
$_SESSION['email'] = $resultat[0]['email'];
|
|
$_SESSION['display_name'] = $resultat[0]['display_name'];
|
|
$_SESSION['userid'] = $resultat[0]['ID'];
|
|
$_SESSION['role'] = $resultat[0]['role'];
|
|
header("Location: index.php");
|
|
exit();
|
|
} else {
|
|
$status = "Nom d'utilisateur / mot de passe incorrect";
|
|
}
|
|
}
|
|
}
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="fr">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<link rel="stylesheet" href="./src/css/style.css">
|
|
<link rel="icon" href="src/img/favicon.ico">
|
|
<title><?=$title?></title>
|
|
</head>
|
|
<body>
|
|
<header>
|
|
<div class="pancontent">
|
|
<div class="athena-container">
|
|
<a href="/" class="athena-link">
|
|
<img src="./src/img/athena-mono.png" class="athena">
|
|
</a>
|
|
</div>
|
|
<div class="content">
|
|
<div>
|
|
<div class="main-title">
|
|
<div class="title"><?=$header_title?></div>
|
|
<div class="subtitle"><?=$header_subtitle?></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
<nav>
|
|
<div class="pancontent">
|
|
<?php nav($nav);?>
|
|
</div>
|
|
</nav>
|
|
<main>
|
|
<div class="content">
|
|
<div><form action="#" method="post">
|
|
<div>
|
|
<div><input type="text" name="username" placeholder="Nom d'utilisateur" required></div>
|
|
<div><input type="password" name="password" placeholder="Mot de Passe" required></div>
|
|
<div><input type="submit" value="Connexion"></div>
|
|
<div><?$status?></div>
|
|
</div>
|
|
</div></form>
|
|
</div>
|
|
</main>
|
|
<footer>
|
|
<div class="content">
|
|
<div>
|
|
<div><?=$copyright?></div>
|
|
</div>
|
|
</div>
|
|
</footer>
|
|
</body>
|
|
</html>
|