first commit
This commit is contained in:
123
views/event.php
Normal file
123
views/event.php
Normal file
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
session_start();
|
||||
include "../controler/database.php";
|
||||
|
||||
|
||||
if(isset($_GET['recherche']) && !empty($_GET['recherche'])){
|
||||
$recherche = $_GET['recherche'];
|
||||
$stmt = $mysqli->prepare("SELECT id, titre, adresse, description_ FROM evenement WHERE titre LIKE ?");
|
||||
$terme = "%" . $recherche . "%";
|
||||
$stmt->bind_param("s", $terme);
|
||||
} else {
|
||||
$stmt = $mysqli->prepare("SELECT id, titre, adresse, description_ FROM evenement");
|
||||
}
|
||||
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($id, $titre, $adresse, $description);
|
||||
|
||||
$evenements = [];
|
||||
|
||||
while ($stmt->fetch()) {
|
||||
$evenements[] = [
|
||||
'id' => $id,
|
||||
'titre' => $titre,
|
||||
'adresse' => $adresse,
|
||||
'description' => $description
|
||||
];
|
||||
}
|
||||
$stmt->close();
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Événements</title>
|
||||
<link rel="stylesheet" href="../css/event.css">
|
||||
</head>
|
||||
|
||||
<?php
|
||||
if(!isset($_SESSION['pseudo'])){
|
||||
include '../controler/menunav-inv.php';
|
||||
} else {
|
||||
include '../controler/menunav-user.php';
|
||||
}
|
||||
?>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="page-header">
|
||||
<h2>Liste des Événements</h2>
|
||||
<!-- Barre de recherche -->
|
||||
<form method="GET" class="recherche-form">
|
||||
<input type="text" name="recherche" placeholder="Rechercher un événement..."
|
||||
value="<?php echo isset($_GET['recherche']) ? $_GET['recherche'] : ''; ?>"
|
||||
class="recherche-input">
|
||||
<button type="submit" class="recherche-btn">Rechercher</button>
|
||||
<?php if(isset($_GET['recherche'])): ?>
|
||||
<a href="event.php" class="effacer-link">Effacer</a>
|
||||
<?php endif; ?>
|
||||
</form>
|
||||
|
||||
<?php if (isset($_GET['inscription'])) : ?>
|
||||
<?php if ($_GET['inscription'] === "ok") : ?>
|
||||
<p class="message success">✅ Inscription réussie !</p>
|
||||
<?php elseif ($_GET['inscription'] === "deja") : ?>
|
||||
<p class="message warning">⚠️ Vous êtes déjà inscrit à cet événement.</p>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="evenement-container">
|
||||
<!-- -->
|
||||
<?php foreach ($evenements as $event) : ?>
|
||||
|
||||
<div class="evenement-card">
|
||||
<h3><?php echo htmlspecialchars($event['titre']); ?></h3>
|
||||
<p><strong>Adresse 📍:</strong> <?php echo htmlspecialchars($event['adresse']); ?></p>
|
||||
<p><?php echo nl2br(htmlspecialchars($event['description'])); ?></p>
|
||||
|
||||
<!-- Affichage des commentaires -->
|
||||
<div class="commentaires">
|
||||
<h4>Commentaires :</h4>
|
||||
<?php
|
||||
$stmtCom = $mysqli->prepare("SELECT c.contenu, c.datepublication, u.pseudo
|
||||
FROM commentaire c
|
||||
JOIN utilisateur u ON c.id_utilisateur = u.id
|
||||
WHERE c.id_evenement = ?
|
||||
ORDER BY c.datepublication DESC");
|
||||
$stmtCom->bind_param("i", $event['id']);
|
||||
$stmtCom->execute();
|
||||
$stmtCom->bind_result($contenu, $date, $auteur);
|
||||
while ($stmtCom->fetch()) {
|
||||
echo "<div class='commentaire'>";
|
||||
echo "<p><strong>👤 " . htmlspecialchars($auteur) . " — " . htmlspecialchars($date) . "</strong><br>" .
|
||||
nl2br(htmlspecialchars($contenu)) . "</p>";
|
||||
echo "</div>";
|
||||
}
|
||||
$stmtCom->close();
|
||||
?>
|
||||
</div>
|
||||
|
||||
<!-- Formulaires -->
|
||||
<?php if (isset($_SESSION['pseudo'])) : ?>
|
||||
<form action="ajout_commentaire.php" method="post">
|
||||
<input type="hidden" name="id_evenement" value="<?php echo $event['id']; ?>">
|
||||
<textarea class="commentaire-textarea" name="contenu" placeholder="Ton commentaire..." required></textarea>
|
||||
<button class="inscrire-btn" type="submit">Envoyer</button>
|
||||
</form>
|
||||
|
||||
<form action="inscription_event.php" method="post">
|
||||
<input type="hidden" name="id_evenement" value="<?php echo $event['id']; ?>">
|
||||
<button type="submit" class="inscrire-btn">S'inscrire</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php endforeach; ?>
|
||||
|
||||
<!-- -->
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user