function buildDetailTable() { $tableauDetail = "<table>"; if (isset($_REQUEST['id'])) { $idUserSearch = $_REQUEST['id']; } $value = selectOneUser($idUserSearch); $tableauDetail .= "<tr><td> Nom </td><td> Prenom </td><td> Date de naissance </td><td> Description </td><td> Pseudo </td><td> Email </td></tr>"; $tableauDetail .= "<tr><td>" . $value['nom'] . "</td><td>" . $value['prenom'] . "</td><td>" . $value['dateNaissance'] . "</td><td>" . $value['description'] . "</td><td>" . $value['pseudo'] . "</td><td>" . $value['email'] . "</td></tr>"; $tableauDetail .= "<tr class='noBorder'><td class='noBorder'></td><td class='noBorder'></td><td class='noBorder'></td><td class='noBorder'></td><td class='noBorder'></td><td class='noBorder'><a href='affichageUsers.php'>Back</a></td></tr>"; $tableauDetail .= "</table>"; return $tableauDetail; }
$idSession = $_SESSION['idUser']; } // On part du principe que l'on n'est pas sur la page pour modifier un utilisateur $modifUser = false; $nom = ""; $prenom = ""; $email = ""; $dateNaissance = ""; $pseudo = ""; $desc = ""; $id = ""; // On vérifie si une variable get id est présente. Si c'est le cas, c'est qu'on est là pour modifier un utilisateur. if (isset($_GET['id'])) { $id = $_REQUEST['id']; $modifUser = true; $tableau = selectOneUser($id); foreach ($tableau as $data) { $idUser = $data['idUser']; $nom = $data['nom']; $prenom = $data['prenom']; $email = $data['email']; $dateNaissance = $data['dateNaissance']; $pseudo = $data['pseudo']; $desc = $data['description']; } } // Récupérer les classes $classes = getClasses(); if ($idSession == $id) { $isHimself = true; }
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <h1>Utilisateurs dans la base de données</h1> <div> <?php if (isset($_GET['idToDelete'])) { $idToDelete = $_REQUEST['idToDelete']; deleteUser($idToDelete); } if (!isset($_GET['id'])) { buildTable(selectAllUsers()); } else { $id = $_REQUEST['id']; buildTableOneUser(selectOneUser($id)); } ?> </div> <br /> <?php echo $stateConnection; ?> <br /><br /> <a href="index.php">Index</a> - <a href="login.php">Login</a> - <a href="utilisateurs.php">Utilisateurs</a> - <a href="choisirSport.php">Chosir un sport</a> </body> </html> <?php
} } if (isset($_REQUEST['id']) && !empty($_REQUEST['id'])) { $idUserSearch = $_REQUEST['id']; $value = selectOneUser($idUserSearch); $id = $value['idUser']; $nom = $value['nom']; $prenom = $value['prenom']; $birthday = $value['dateNaissance']; $description = $value['description']; $email = $value['email']; $pseudo = $value['pseudo']; $placeholder = "Laissez vide si vous ne voulez pas le changer!"; } if (isset($_REQUEST['Modifier'])) { $value = selectOneUser($idUserSearch); $nom = $_REQUEST['nom']; $prenom = $_REQUEST['prenom']; $birthday = $_REQUEST['birthday']; $description = $_REQUEST['description']; $email = $_REQUEST['email']; $pseudo = $_REQUEST['pseudo']; $admin = $_REQUEST['grpAdmin']; if (!isset($_REQUEST['password'])) { $password = $value['mdp']; } else { $password = $_REQUEST['password']; } updateUser($nom, $prenom, $birthday, $description, $email, $pseudo, $password, $id, $admin); header('location:affichageUsers.php'); }