added admin page
parent
4ea87ca98a
commit
11e0e4f486
@ -0,0 +1,106 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once('../connexionBD.php');
|
||||
require_once ('../ressources/user.php');
|
||||
|
||||
$mail = $_SESSION['mail'];
|
||||
|
||||
if (!isset($_SESSION['mail'])) {
|
||||
header('Location: index.php');
|
||||
exit();
|
||||
}
|
||||
|
||||
$user = getUser($db, $mail);
|
||||
|
||||
if (!$user){
|
||||
header('Location: profil.php?error=3');
|
||||
exit();
|
||||
}
|
||||
|
||||
if (isset($_POST['login']) || isset($_FILES['avatar'])){
|
||||
if (isset($_FILES['avatar']) and !empty($_FILES['avatar']['name'])) {
|
||||
$fic = $_FILES['avatar'];
|
||||
supprimerAvatar($mail);
|
||||
$res = uploadAvatar($mail, $fic);
|
||||
switch ($res){
|
||||
case -1:
|
||||
header('Location: profil.php?error=4');
|
||||
exit();
|
||||
case -2:
|
||||
header('Location: profil.php?error=5');
|
||||
exit();
|
||||
case -3:
|
||||
header('Location: profil.php?error=6');
|
||||
exit();
|
||||
}
|
||||
}
|
||||
if (isset($_POST['login']) && isset($_POST['password']) && isset($_POST['confirmation']) && isset($_POST['prenom']) && isset($_POST['nom']) && isset($_POST['phone'])) {
|
||||
$login = htmlentities(pg_escape_string($_POST['login']));
|
||||
$password = htmlentities(pg_escape_string($_POST['password']));
|
||||
$confirmation = htmlentities(pg_escape_string($_POST['confirmation']));
|
||||
$prenom = htmlentities(pg_escape_string($_POST['prenom']));
|
||||
$nom = htmlentities(pg_escape_string($_POST['nom']));
|
||||
$phone = htmlentities(pg_escape_string($_POST['phone']));
|
||||
|
||||
if (loginChange($user, $login)) {
|
||||
if (!isLoginUniqueModifier($db, $mail, $login)) {
|
||||
header('Location: profil.php?error=1');
|
||||
exit();
|
||||
} else {
|
||||
if (!modifierLogin($db, $mail, $login)) {
|
||||
header('Location: profil.php?error=6');
|
||||
exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (strcmp($password, $confirmation) != 0) {
|
||||
header('Location: profil.php?error=2');
|
||||
exit();
|
||||
}
|
||||
if (!modifierUtilisateur($db, $mail, $prenom, $nom, $password, $phone)) {
|
||||
header('Location: profil.php?error=6');
|
||||
exit();
|
||||
}
|
||||
}
|
||||
sleep(0.85);
|
||||
header('Location: profil.php');
|
||||
exit();
|
||||
}
|
||||
|
||||
$delmail = $_POST['delmail'];
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<link rel="stylesheet" href="admin.css">
|
||||
<link rel="stylesheet" href="../ressources/navbaradminhtml.css">
|
||||
<link rel="stylesheet" href="../index.css">
|
||||
<script src="../inscription/inscription.js"></script>
|
||||
<title>Administration</title>
|
||||
</head>
|
||||
<body>
|
||||
<?php require_once("../ressources/navbaradminhtml.php"); ?>
|
||||
<div id="formulaire">
|
||||
<h1>Administration</h1>
|
||||
<div>
|
||||
<h1>Supprimer un utilisateur</h1>
|
||||
<fieldset>
|
||||
<form action="admin.php" method="post">
|
||||
<table>
|
||||
<tr>
|
||||
<td><p>mail de l'utilisateur a supprimer :</p></td>
|
||||
<td><input type="text" name="delmail"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><p><input type="submit" name="deluserbutton" value="supprimer l'utilisateur"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php if (isset($_POST['delmail'])) { deluser($delmail); }?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</fieldset>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,39 @@
|
||||
#menuDiv{
|
||||
width: 100%;
|
||||
display: block;
|
||||
}
|
||||
|
||||
#menuDiv a{
|
||||
font-family: "Arial";
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
#menu {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
background-color: rgb(65, 154, 28);
|
||||
}
|
||||
|
||||
.menuItem {
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: white;
|
||||
width: 10%;
|
||||
min-width: 5em;
|
||||
font-weight: bold;
|
||||
text-decoration: none;
|
||||
padding: 0.8em;
|
||||
border-bottom: 4px solid rgb(65, 154, 28);
|
||||
border-top: 4px solid rgb(65, 154, 28);
|
||||
font-size: 1.1em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.menuItem:hover{
|
||||
cursor: pointer;
|
||||
border-bottom: 4px solid orange;
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
$path = "..";
|
||||
if (file_exists("./inscription.php")) {
|
||||
$path = ".";
|
||||
}
|
||||
?>
|
||||
<div id="menuDiv">
|
||||
<nav id="menu">
|
||||
<a class="menuItem" href="<?php echo $path ; ?>/tableauBord/tableauBord.php">Tableau de bord</a>
|
||||
<a class="menuItem" href="<?php echo $path ; ?>/inscription.php">Trajets publiés</a>
|
||||
<a class="menuItem" href="<?php echo $path ; ?>/inscription.php">Trajets réservés</a>
|
||||
<a class="menuItem" href="<?php echo $path ; ?>/inscription.php">Messagerie</a>
|
||||
<a class="menuItem" href="<?php echo $path ; ?>/inscription.php">Avis reçus</a>
|
||||
<a class="menuItem" href="<?php echo $path ; ?>/inscription.php">Avis laissés</a>
|
||||
<a class="menuItem" href="<?php echo $path ; ?>/admin/admin.php">Administration</a>
|
||||
<a class="menuItem" href="<?php echo $path ; ?>/deconnexion.php">Se déconnecter</a>
|
||||
</nav>
|
||||
</div>
|
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
function addVoiture($db, $matricule, $marque, $modele, $nbplaces, $anneefab){
|
||||
$requete = "INSERT INTO public.voiture (matricule, marque, modele, nbplaces, anneefab, mail) VALUES ('" . $matricule . "','" . $marque . "','" . $modele . "','" . $nbplaces . "','" . $anneefab . "','" . $_SESSION['mail'] . "');";
|
||||
pg_query($db, $requete);
|
||||
}
|
||||
|
||||
function changeVoiture($db, $matricule, $marque, $modele, $nbplaces, $anneefab){
|
||||
$requete = "UPDATE public.voiture SET (matricule, marque, modele, nbplaces, anneefab) = ('" . $matricule . "','" . $marque . "','" . $modele . "','" . $nbplaces . "','" . $anneefab . "') WHERE mail = '" . $_SESSION['mail'] . "';";
|
||||
pg_query($db, $requete);
|
||||
}
|
||||
|
||||
function showVoiture($db){
|
||||
$requete = "SELECT * FROM public.voiture WHERE voiture.mail = '" . $_SESSION['mail'] . "';";
|
||||
if ($donnees = pg_query($db, $requete)) {
|
||||
while ($res = pg_fetch_assoc($donnees)) {
|
||||
echo "matricule = ".$res['matricule']."<br>";
|
||||
echo "marque = ".$res['marque']."<br>";
|
||||
echo "modele = ".$res['modele']."<br>";
|
||||
echo "nombre de places = ".$res['nbplaces']."<br>";
|
||||
echo "année de fabrication = ".$res['anneefab']."<br>";
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in New Issue