Web/TP/TPSecurite/article_list.php

41 lines
573 B
PHP
Raw Permalink Normal View History

2023-05-25 11:50:30 +02:00
<?php
require_once 'lib/common.php';
session_start();
$db = initDatabase();
$req = mysqli_query($db,"SELECT * FROM article");
$articles=mysqli_fetch_all($req);
?>
<?php
include './templates/header.php';
?>
<body container>
<h1>Liste des articles</h1>
<?php
if (!empty($_SESSION['user'])) {
echo "<p>Bonjour, " . $_SESSION['user']['name']. ".</p>";
}
?>
<ul>
<?php
foreach ($articles as $article) {
echo '<li><a href="article_view.php?id=' . $article[0].'">'
. $article[1] . "</a></li>\n";
}
?>
</ul>
<?php
include './templates/footer.php';
?>
</body>
</html>