forked from ghouar-t/SaeDEV2.2
Upload files to "php"
This commit is contained in:
parent
abe7bcde0b
commit
c526f65782
100
php/creer_event.php
Normal file
100
php/creer_event.php
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="fr">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<link rel="icon" href="../img/jo2024.jpg">
|
||||||
|
<link rel="stylesheet" href="../css/style.css">
|
||||||
|
<title>Création évènement - Jeux Olympiques</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// Informations de connexion à la base de données
|
||||||
|
require_once 'common.php';
|
||||||
|
session_start();
|
||||||
|
$db = initDatabase();
|
||||||
|
|
||||||
|
if (!empty($_POST['nom'])) {
|
||||||
|
|
||||||
|
// Utiliser htmlspecialchars pour échapper les caractères spéciaux
|
||||||
|
$nom = htmlspecialchars($_POST['nom'], ENT_QUOTES, 'UTF-8');
|
||||||
|
$sport = htmlspecialchars($_POST['sport'], ENT_QUOTES, 'UTF-8');
|
||||||
|
$lieu = htmlspecialchars($_POST['lieu'], ENT_QUOTES, 'UTF-8');
|
||||||
|
$date = htmlspecialchars($_POST['date'], ENT_QUOTES, 'UTF-8');
|
||||||
|
$description = htmlspecialchars($_POST['description'], ENT_QUOTES, 'UTF-8');
|
||||||
|
|
||||||
|
// Récupérer le dernier ID et calculer le nouvel ID
|
||||||
|
$recupid = mysqli_query($db, "SELECT MAX(id) AS max_id FROM evenement");
|
||||||
|
$row = mysqli_fetch_assoc($recupid);
|
||||||
|
$id = $row['max_id'] + 1;
|
||||||
|
|
||||||
|
// Préparer la requête SQL
|
||||||
|
$stmt = mysqli_prepare($db, "INSERT INTO evenement (id, nom, sport, lieux, date, description, nbinscrit) VALUES (?, ?, ?, ?, ?, ?, ?)");
|
||||||
|
|
||||||
|
// Vérifier si la requête a été préparée avec succès
|
||||||
|
if ($stmt === false) {
|
||||||
|
die("Erreur de préparation de la requête : " . mysqli_error($db));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lier les paramètres à la requête préparée
|
||||||
|
$statut = 0; // Valeur par défaut pour le statut
|
||||||
|
mysqli_stmt_bind_param($stmt, 'isssssi', $id, $nom, $sport, $lieu, $date, $description, $statut);
|
||||||
|
|
||||||
|
// Exécuter la requête
|
||||||
|
if (mysqli_stmt_execute($stmt)) {
|
||||||
|
header('Location: evenement.php');
|
||||||
|
exit();
|
||||||
|
} else {
|
||||||
|
die("Erreur d'exécution de la requête : " . mysqli_stmt_error($stmt));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fermer la requête
|
||||||
|
mysqli_stmt_close($stmt);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fermer la connexion
|
||||||
|
mysqli_close($db);
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<header>
|
||||||
|
<h1 class='Hello'> Page de création d'évènement </h1>
|
||||||
|
<nav>
|
||||||
|
<?php
|
||||||
|
if (isset($_SESSION['login'])) {
|
||||||
|
echo "<a href='https://dwarves.iut-fbleau.fr/~ghouar-t/SaeDEV2.2/' class='categorie'>Page d'accueil</a>";
|
||||||
|
echo "<a href='https://dwarves.iut-fbleau.fr/~ghouar-t/SaeDEV2.2/php/profil.php'><img class='profil' src='https://dwarves.iut-fbleau.fr/~ghouar-t/SaeDEV2.2/img/photo-profil.png' alt='profil'></a>";
|
||||||
|
echo "<a href='https://dwarves.iut-fbleau.fr/~ghouar-t/SaeDEV2.2/php/.php' class='categorie'>Déconnexion</a>";
|
||||||
|
} else {
|
||||||
|
echo "<a href='https://dwarves.iut-fbleau.fr/~ghouar-t/SaeDEV2.2/' class='categorie'>Page d'accueil</a>";
|
||||||
|
echo "<a href='https://dwarves.iut-fbleau.fr/~ghouar-t/SaeDEV2.2/php/connexion.php' class='categorie'>Connexion</a>";
|
||||||
|
echo "<a href='https://dwarves.iut-fbleau.fr/~ghouar-t/SaeDEV2.2/php/inscription.php' class='categorie'>Inscription</a>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div class="inscription" id="inscription">
|
||||||
|
<u><i><h2>Inscription</h2></i></u><br>
|
||||||
|
<form action="" method="post">
|
||||||
|
<label for="nom">Nom évènement:</label><br>
|
||||||
|
<input type="text" id="nom" name="nom" required><br><br>
|
||||||
|
<label for="sport">Sport :</label><br>
|
||||||
|
<input type="text" id="sport" name="sport" required><br><br>
|
||||||
|
<label for="lieu">Lieu :</label><br>
|
||||||
|
<input type="text" id="lieu" name="lieu" required><br><br>
|
||||||
|
<label for="date">Date :</label><br>
|
||||||
|
<input type="date" id="date" name="date" required><br><br>
|
||||||
|
<label for="description">Description :</label><br>
|
||||||
|
<input type="text" id="description" name="description" required><br><br>
|
||||||
|
<button type="submit" class="submit">Créer un évènement</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<footer>
|
||||||
|
<?php require_once('footer.php'); ?>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -1,14 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once 'lib/common.php';
|
require_once 'common.php';
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
$db = initDatabase();
|
$db = initDatabase();
|
||||||
|
|
||||||
if (empty($_REQUEST['id_article'])) {
|
if (empty($_REQUEST['id_article'])) {
|
||||||
header('Location: article_list.php');
|
header('Location: evenement.php');
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
if (!empty($_GET['title']) && !empty($_GET['content'])) {
|
if (!empty($_GET['tit']) && !empty($_GET['content'])) {
|
||||||
$title = $_GET['title'];
|
$title = $_GET['title'];
|
||||||
$content = htmlspecialchars($_GET['content']);
|
$content = htmlspecialchars($_GET['content']);
|
||||||
if (empty($_GET['id_comment'])) { // nouveau ou modif ?
|
if (empty($_GET['id_comment'])) { // nouveau ou modif ?
|
||||||
@ -38,7 +38,6 @@ include './templates/header.php';
|
|||||||
echo '<input name="id_comment" type="hidden" value="' . $_REQUEST['id_comment'] ."\" />\n";
|
echo '<input name="id_comment" type="hidden" value="' . $_REQUEST['id_comment'] ."\" />\n";
|
||||||
} ?>
|
} ?>
|
||||||
<input name="id_article" type="hidden" value="<?php echo $_REQUEST['id_article']; ?>" />
|
<input name="id_article" type="hidden" value="<?php echo $_REQUEST['id_article']; ?>" />
|
||||||
<div><label> Titre <input name="title" type="text" value="" size="60" /></label></div>
|
|
||||||
<div> <label> Texte <textarea name="content" cols="60" rows="6"></textarea></label></div>
|
<div> <label> Texte <textarea name="content" cols="60" rows="6"></textarea></label></div>
|
||||||
<button type="submit" name="ok" value="1">Ajouter ce commentaire</button>
|
<button type="submit" name="ok" value="1">Ajouter ce commentaire</button>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
@ -76,6 +76,14 @@ $event = mysqli_stmt_get_result($stmt);
|
|||||||
?>
|
?>
|
||||||
</nav>
|
</nav>
|
||||||
</header>
|
</header>
|
||||||
|
<?php
|
||||||
|
if (isset($_SESSION['role'])) {
|
||||||
|
if ($_SESSION['role']=='organizer') {
|
||||||
|
echo "<a href='creer_event.php' class='categorie'>Connexion</a>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
<div class="ListeEvenement">
|
<div class="ListeEvenement">
|
||||||
<div>
|
<div>
|
||||||
<h2>Liste des Évenements :</h2>
|
<h2>Liste des Évenements :</h2>
|
||||||
@ -101,7 +109,7 @@ $event = mysqli_stmt_get_result($stmt);
|
|||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php
|
||||||
while ($row = mysqli_fetch_assoc($event)) {
|
while ($row = mysqli_fetch_assoc($event)) {
|
||||||
echo "<tr> <td scope='row'><a href='/~ghouar-t/SaeDEV2.2/CI3/index.php/Evenement_info/view/{$row['id']}'><br>".$row['Nom']."</td><td><br>".$row['Sport']."</td><td><br>".$row['Lieux']."</td><td><br>".$row['Date']."</td><td><br>".$row['NbInscrit']."</td></tr>";
|
echo "<tr> <td scope='row'><a href='event.php?id=".$row['id']."'><br>".$row['Nom']."</td><td><br>".$row['Sport']."</td><td><br>".$row['Lieux']."</td><td><br>".$row['Date']."</td><td><br>".$row['NbInscrit']."</td></tr>";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
93
php/event.php
Normal file
93
php/event.php
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
<?php
|
||||||
|
require_once 'common.php';
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
if (empty($_GET['id'])) {
|
||||||
|
header('Location: evenement.php');
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$db = initDatabase();
|
||||||
|
$req = mysqli_query($db,"SELECT * FROM evenement WHERE id=" .$_GET['id']);
|
||||||
|
$event=mysqli_fetch_assoc($req);
|
||||||
|
|
||||||
|
$req = mysqli_query($db,"SELECT * FROM commentaire WHERE id_event=" . $_GET['id']);
|
||||||
|
$commentaire=mysqli_fetch_all($req,MYSQLI_ASSOC);
|
||||||
|
?>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<link rel="icon" href="../img/jo2024.jpg">
|
||||||
|
<link rel="stylesheet" href="../css/style.css">
|
||||||
|
<title>Évènements - Jeux Olympiques</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
<h1 class='Hello'>Évènement</h1>
|
||||||
|
<nav>
|
||||||
|
<?php
|
||||||
|
if (isset($_SESSION['login'])) {
|
||||||
|
echo " <a href='../' class='categorie'>Page d'accueil</a>";
|
||||||
|
echo " <a href='profil.php'><img class='profil' src='https://dwarves.iut-fbleau.fr/~ghouar-t/SaeDEV2.2/img/photo-profil.png' alt='profil'></a>";
|
||||||
|
echo "<a href='deconnexion.php' class='categorie'>Déconnexion</a>";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
echo "<a href='../' class='categorie'>Page d'accueil</a>";
|
||||||
|
echo "<a href='connexion.php' class='categorie'>Connexion</a>";
|
||||||
|
echo "<a href='inscription.php' class='categorie'>Inscription</a>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<body container>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
echo '<div id="article">'
|
||||||
|
. '<h3>'. $event['title'] .'</h3>'
|
||||||
|
. '<div id="content">' . $event['description'] . '</div>';
|
||||||
|
|
||||||
|
echo '<h5 class="_bb1">Commentaires</h5>';
|
||||||
|
if (empty($commentaire)) {
|
||||||
|
echo '<p>Aucun</p>';
|
||||||
|
} else {
|
||||||
|
foreach ($commentaire as $com) {
|
||||||
|
echo '<section class="alert-box">';
|
||||||
|
echo "<b class='_ts2'>".$com['title']."</b>"
|
||||||
|
. (isset($_SESSION['user']['id']) && $com['id_user'] == $_SESSION['user']['id'] ?
|
||||||
|
' <a href="comment_create.php?id_article=' . $com['id_article']
|
||||||
|
. '&id_comment=' . $com['id'] . '" title="'. $com['title']
|
||||||
|
. '">Modifier ce commentaire</a>' :
|
||||||
|
'')
|
||||||
|
. '<p class="_ts2">' . $comment['content'] ."</p>"
|
||||||
|
. "<p><span class='tag-box -warning'><a href=\"".$comment['url']."\">".$comment['login']."</a></p>";
|
||||||
|
echo "</section>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo "</div>";
|
||||||
|
|
||||||
|
if (empty($_SESSION['user'])) {
|
||||||
|
echo '<p>Il faut être identifié pour poster un commentaire.</p>';
|
||||||
|
} else {
|
||||||
|
if ($article['closed']) {
|
||||||
|
echo "<p>Article fermé, non modifiable.</p>";
|
||||||
|
} else {
|
||||||
|
echo '<p> <a href="comment_create.php?id_article='. $article['id']
|
||||||
|
.'">Ajouter un commentaire</a> avec votre compte : ' . $_SESSION['user']['name']
|
||||||
|
.' </p>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<p> <a href="article_list.php">Retour à la liste des articles</a> </p>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
include 'footer.php';
|
||||||
|
?>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue
Block a user