acces + font (acces et connexion)

This commit is contained in:
Baptiste 2022-06-15 21:00:54 +02:00
parent 29c6d00b66
commit 7013a85a10
3 changed files with 99 additions and 21 deletions

View file

@ -1,8 +1,8 @@
* {
margin: 0;
padding: 0;
--color1 : rgba(30, 30, 30, 1);
--color2 : rgba(255, 255, 255, 0.07);
--color1 : rgb(30, 30, 30);
--color2 : rgb(46,46,46);
}
body {
@ -61,7 +61,7 @@ table.acces {
table.acces th {
background-color: var(--color2);
padding: 20px;
border: 0;
border: 3px solid var(--color2);
text-align: center;
color: white;
}
@ -70,4 +70,57 @@ table.acces td {
border: 3px solid var(--color2);
padding: 20px;
text-align: center;
}
.input {
display: block;
margin: 30px;
padding: 10px;
background-color: var(--color1);
color: white;
border: 3px solid white;
}
.submit {
display: block;
padding: 10px;
margin: 30px;
background-color: var(--color1);
color: white;
border: 3px solid white;
}
.submit:hover {
transition: 0.2s ease;
transform: scale(1.05);
}
.input_inline {
display: inline-block;
margin: 10px;
padding: 10px;
background-color: var(--color1);
color: white;
border: 3px solid white;
}
.submit_inline {
display: inline-block;
padding: 10px;
margin: 10px;
background-color: var(--color1);
color: white;
border: 3px solid white;
}
.submit_inline:hover {
display: inline-block;
transition: 0.2s ease;
transform: scale(1.05);
}
.cross {
text-decoration: none;
color: red;
font-weight: bold;
}

View file

@ -5,11 +5,35 @@ if($user['perm'] < 2) {
header('Location: deco.php');
}
if(isset($_GET['del']) AND !empty(['del']))
{
if($user['perm'] >= 2) {
$del = (int) htmlspecialchars($_GET['del']);
$req = $db->prepare('DELETE FROM admin WHERE id =?');
$req->execute(array($del));
header('Location: gestion_des_acces.php');
}
}
if(isset($_POST['send'])) {
if(isset($_POST['pseudo']) AND !empty($_POST['pseudo']) AND isset($_POST['mdp']) AND !empty($_POST['mdp']) AND isset($_POST['perm']) AND !empty($_POST['perm'])) {
$pseudo = htmlspecialchars($_POST['pseudo']);
$mdp = htmlspecialchars($_POST['mdp']);
$perm = (int) htmlspecialchars($_POST['perm']);
$perm = htmlspecialchars($_POST['perm']);
switch ($perm) {
case "v0":
$perm_int = 0;
break;
case "v1":
$perm_int = 1;
break;
case "v2":
$perm_int = 3;
break;
}
if(strlen($pseudo) <= 50) {
$req = $db->prepare("SELECT id FROM admin WHERE pseudo = ?");
@ -17,7 +41,8 @@ if(isset($_POST['send'])) {
$pseudo_exist = $req->rowCount();
if ($pseudo_exist == 0) {
$req = $db->prepare("INSERT INTO admin(pseudo, mdp, perm) VALUES(?, ?, ?)");
$req->execute(array($pseudo, password_hash($mdp, PASSWORD_DEFAULT), $perm));
$req->execute(array($pseudo, password_hash($mdp, PASSWORD_DEFAULT), $perm_int));
header('refresh:0');
} else {
$error = "pseudo déja utilisé";
}
@ -39,14 +64,14 @@ if(isset($_POST['send'])) {
<body>
<main>
<form method="POST">
<input type="text" placeholder="identifiant" name="pseudo">
<input type="password" placeholder="mot de passe" name="mdp">
<select name="perm">
<option value="0">GDA - Perm 0</option>
<option value="1">Bureau - Perm 1</option>
<option value="2">Admin - Perm 2</option>
<input type="text" placeholder="identifiant" name="pseudo" class="input_inline">
<input type="password" placeholder="mot de passe" name="mdp" class="input_inline">
<select name="perm" class="input_inline">
<option value="v0">GDA - Perm 0</option>
<option value="v1">Bureau - Perm 1</option>
<option value="v2">Admin - Perm 2</option>
</select>
<input type="submit" name="send" value="Creer l'acces">
<input type="submit" name="send" value="Creer l'acces" class="submit_inline">
</form>
<?php
if(isset($error)) {
@ -56,10 +81,10 @@ if(isset($_POST['send'])) {
<br><br>
<table class="acces">
<tr>
<th width="20%">ID (db)</td>
<th width="20%">Identifiant</td>
<th width="20%">Perm</td>
<th width="40%"></td>
<th width="10%">ID (db)</td>
<th width="40%">Identifiant</td>
<th width="40%">Perm</td>
<th width="10%">Actions</td>
</tr>
<?php
$req = $db->query('SELECT id, pseudo, perm FROM admin');
@ -69,7 +94,7 @@ if(isset($_POST['send'])) {
<td><?= $admin['id'] ?></td>
<td><?= $admin['pseudo'] ?></td>
<td><?php
switch ($user['perm']) {
switch ($admin['perm']) {
case 0:
echo "<font color='green'>GDA</font>";
break;
@ -81,7 +106,7 @@ if(isset($_POST['send'])) {
break;
}
?></td>
<td></td>
<td><a href="?del=<?= $admin['id'] ?>" class="cross">X</a></td>
</tr>
<?php } ?>
</table>

View file

@ -42,9 +42,9 @@ if(isset($_POST['login'])) {
} else {
?>
<form method="POST">
<input type="text" placeholder="Identifiant" name="pseudo">
<input type="password" placeholder="mot de passe" name="password">
<input type="submit" name="login" value="Se connecter">
<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">
</form>
<?php
}