This repository has been archived on 2025-02-26. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
tp_twigg/crud/details.php
2024-10-11 15:25:45 +02:00

46 lines
1.2 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
session_start();
// On inclut la connexion à la base
require_once('connect.php');
if (isset($_GET['id']) && !empty($_GET['id'])) {
$id = strip_tags($_GET['id']);
// On écrit notre requête
$sql = 'SELECT * FROM `users` WHERE `id`=:id';
// On prépare la requête
$query = $db->prepare($sql);
// On attache les valeurs
$query->bindValue(':id', $id, PDO::PARAM_STR);
// On exécute la requête
$query->execute();
// On stocke le résultat dans un tableau associatif
$user = $query->fetch();
if (!$user) {
header('Location: index.php');
}
} else {
header('Location: index.php');
}
require_once('close.php');
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Liste des produits</title>
</head>
<body>
<h1>Détails pour lutilisateur <?= $user['login'] ?></h1>
<p>ID : <?= $user['id'] ?></p>
<p>Login : <?= $user['login'] ?></p>
<p>FirstName : <?= $user['firstname'] ?></p>
<p>LastName : <?= $user['lastname'] ?></p>
<p>Role : <?= $user['role'] ?></p>
<p><a href="edit.php?id=<?= $user['id'] ?>">Modifier</a>
<a href="delete.php?id=<?= $user['id'] ?>">Supprimer</a>
</p>
</body>
</html>