Skip to content

Commit

Permalink
tyt
Browse files Browse the repository at this point in the history
  • Loading branch information
adriendelagneau committed Aug 18, 2021
1 parent 93e5e17 commit 5cafe96
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 28 deletions.
32 changes: 26 additions & 6 deletions app/Controllers/back/BackController.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,12 +328,26 @@ public function updateUser($userId, $userName, $userFirstname, $userAdress, $use
{
$user = new \Project\Models\UserManager();
$updateUser = $user->updateUser($userId, $userName, $userFirstname, $userAdress, $userPhone, $userMail);
$_SESSION['userName'] = $userName;
$_SESSION['userFirstame'] = $userFirstname;
$_SESSION['userPhone'] = $userPhone;
$_SESSION['userAdress'] = $userAdress;
$_SESSION['userMail'] = $userMail;

/* obliger de fetch() pour mettre à jour la variable de session,
un code type $_SESSION['userName'] = $userName;
ne suffisait pas...
a approfonfir ...*/

$user = new \Project\Models\UserManager();
$userInfos = $user->selectUser($userId);
$result = $userInfos->fetch();

$_SESSION['userId'] = $result['userId'];
$_SESSION['userName'] = $result['userName'];
$_SESSION['userFirstname'] = $result['userFirstname'];
$_SESSION['userPhone'] = $result['userPhone'];
$_SESSION['userAdress'] = $result['userAdress'];
$_SESSION['userMail'] = $result['userMail'];
$_SESSION['userPWD'] = $result['userPWD'];


echo '<script>alert("infos mofifiées avec succes !");</script>';
require 'app/Views/back/tableauDeBordUser.php';
}

Expand All @@ -344,16 +358,22 @@ public function updateMdpUser($ancienMdp, $nouveauMdpCrypte, $nouveauMdpConfirmC
$mdp = new \Project\Models\UserManager();
$newMdp = $mdp->updateMdpUser($nouveauMdpCrypte);

echo '<script>alert("mot de passe mofifié avec succes !");</script>';
require 'app/Views/back/tableauDeBordUser.php';
} else {
echo 'mot de passe incorect';


echo '<script>alert("mot de passe incorect");</script>';

require 'app/Views/back/tableauDeBordUser.php';
}
}

public function deleteUser()
{
$user = new \Project\Models\UserManager();
$deleteUser = $user->deleteUser();
header('Location: indexAdmin.php?action=deconnexion');
}

/*************************** orders ********************************/
Expand Down
7 changes: 7 additions & 0 deletions app/Models/UserManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,12 @@ public function deleteHistory($id)
$req->execute(array($id));
return $req;
}
public function selectUser($userId)
{
$bdd = $this->dbConnect();
$req = $bdd->prepare("SELECT * FROM user WHERE userId = ?");
$req->execute(array($userId));
return $req;
}

}
6 changes: 5 additions & 1 deletion app/Public/back/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,11 @@ header {
#slides .card_articles {
text-align: center;
}

/************** desinscription ***********/
#supUser{
width: 100%;
text-align: center;
}
/************************** ************************
*********************** footer **********************
************************** ************************/
Expand Down
5 changes: 4 additions & 1 deletion app/Views/back/desinscription.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<?php ob_start();?>

<h1> desinscription</h1>
<p>êtes vous sur de vouloiir vous desinscrire, toutes vos informations seront definitivement supprimées.</p>

<div id="supUser">

<p>êtes vous sur de vouloir vous desinscrire, toutes vos informations seront définitivement supprimées.</p>
<p>si oui cliquez ci dessous</p>

<form action="indexAdmin.php?action=deleteUser" method="post">
<input type="submit" value="me desinscrire">
</form>
</div>

<?php $content = ob_get_clean()?>
<?php require 'templates/templateUser.php'?>
17 changes: 0 additions & 17 deletions app/Views/back/listOrders.php

This file was deleted.

2 changes: 1 addition & 1 deletion app/Views/back/listReducs.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<form action="indexAdmin.php?action=selectReduc&id=<?= $reducs['id'] ?>" method="post">
<input type="submit" value="mofifier">
</form>
<form action="indexAdmin.php?action=Reduc&id=<?= $reducs['id'] ?>"method="post">
<form action="indexAdmin.php?action=deleteReduc&id=<?= $reducs['id'] ?>"method="post">
<input type="submit" value="supprimer">
</form>
</div>
Expand Down
7 changes: 5 additions & 2 deletions app/Views/back/listSlides.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@

<p><?= $slides["title"] ?></p>
<p><img src="<?= $slides["imgAdress"] ?>" alt="<?= $slides['title'] ?>"></p>
<a href="indexAdmin.php?action=deleteSlide&id=<?= $slides['id'] ?>"> supprimer cette
slide</a>

<form action="indexAdmin.php?action=deleteSlide&id=<?= $slides['id'] ?>"method="post">
<input type="submit" value="supprimer">
</form>

</div>
<?php } ?>
</section>
Expand Down
1 change: 1 addition & 0 deletions app/Views/back/tableauDeBordUser.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php ob_start(); ?>

<h1>Tableau de bord de : <?php echo $_SESSION["userName"] ?></h1>

<div class="tdb">

<div><a href="indexAdmin.php?action=infosUser">gerrer vos infos</a></div>
Expand Down
2 changes: 2 additions & 0 deletions indexAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@
$userAdress = htmlspecialchars($_POST['userAdress']);
$userPhone = htmlspecialchars($_POST['userPhone']);
$userMail = htmlspecialchars($_POST['userMail']);


$backController->updateUser($userId, $userName, $userFirstname, $userAdress, $userPhone, $userMail);
}
elseif ($_GET['action'] == 'changementMdpUser') {
Expand Down

0 comments on commit 5cafe96

Please sign in to comment.