parent
d64ab6c94b
commit
c116fb230f
@ -0,0 +1,76 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class ControllerUserPlayers
|
||||||
|
{
|
||||||
|
private $mdPlayer;
|
||||||
|
|
||||||
|
private $twig;
|
||||||
|
private $vues;
|
||||||
|
|
||||||
|
function __construct()
|
||||||
|
{
|
||||||
|
global $dns, $user, $pass, $vues, $twig;
|
||||||
|
session_start();
|
||||||
|
try {
|
||||||
|
|
||||||
|
if($_SESSION["idAdminConnected"] != null){
|
||||||
|
$this->twig =$twig;
|
||||||
|
$this->vues = $vues;
|
||||||
|
|
||||||
|
$this->mdPlayer = new ModelPlayer();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
header("Location:/login");
|
||||||
|
}
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
// Gérez les erreurs PDO ici
|
||||||
|
} catch (Exception $e2) {
|
||||||
|
// Gérez d'autres erreurs ici
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function delete($param) {
|
||||||
|
$this->mdPlayer->deleteAdministratorByID($param["id"]);
|
||||||
|
header("Location:/admin/administrators");
|
||||||
|
}
|
||||||
|
|
||||||
|
function add($param) {
|
||||||
|
|
||||||
|
$username = $_POST['username'];
|
||||||
|
$password = $_POST['password'];
|
||||||
|
|
||||||
|
$Player = [
|
||||||
|
'username' => $username,
|
||||||
|
'password' => $password,
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->mdPlayer->addAdministrator($Player);
|
||||||
|
|
||||||
|
header("Location:/loginPlayer");
|
||||||
|
}
|
||||||
|
|
||||||
|
function updatemodal($param) {
|
||||||
|
|
||||||
|
$administrator = $this->mdPlayer->getAdministratorByID($param["id"]);
|
||||||
|
|
||||||
|
echo $this->twig->render($this->vues["adminAdministratorsModal"], [
|
||||||
|
'administrator' => $administrator,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function update($param) {
|
||||||
|
|
||||||
|
$id = $_POST['id'];
|
||||||
|
$username = $_POST['username'];
|
||||||
|
$password = $_POST['password'];
|
||||||
|
|
||||||
|
$Admin = [
|
||||||
|
'username' => $username,
|
||||||
|
'password' => $password,
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->mdPlayer->updateAdministrator($id,$Admin);
|
||||||
|
|
||||||
|
header("Location:/admin/administrators");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="fr">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Math'Educ - Connexion</title>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
|
||||||
|
<link rel="stylesheet" href="css/global.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container mt-5">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-4 offset-md-4">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<h2 class="card-title">Connexion</h2>
|
||||||
|
<form action="/login/verifyPlayer" method="post">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="username" class="form-label">Nom d'utilisateur</label>
|
||||||
|
<input type="text" class="form-control" id="username" name="username" required>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="password" class="form-label">Mot de passe</label>
|
||||||
|
<input type="password" class="form-control" id="password" name="password" required>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary">Se connecter</button>
|
||||||
|
<a href="/user/player/add">S'inscrire</a>
|
||||||
|
<p>{{error}}</p>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in new issue