ajout de la fonctionnalité de participation d'un sportif. Fix du header et footer en conséquence.
Co-authored-by: Charpentier Juliette <juliette.charpentier1@etu.u-pec.fr>
This commit is contained in:
58
events/participate/cancel.php
Normal file
58
events/participate/cancel.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/tools/dbConnect.php';
|
||||
session_start();
|
||||
|
||||
if (isset($_COOKIE['userData'])) {
|
||||
$userData = json_decode($_COOKIE['userData'], true);
|
||||
|
||||
$email = $userData['email'];
|
||||
$name = $userData['name'];
|
||||
$familyName = $userData['familyName'];
|
||||
$role = $userData['role'];
|
||||
}
|
||||
|
||||
if (isset($_GET['usermail']) && isset($_GET['id'])) {
|
||||
$userEmail = $_GET['usermail'];
|
||||
$eventId = $_GET['id'];
|
||||
|
||||
$stmt = mysqli_prepare($db, "SELECT * FROM event_entries WHERE id = ? AND mail = ?");
|
||||
mysqli_stmt_bind_param($stmt, "is", $eventId, $userEmail);
|
||||
mysqli_stmt_execute($stmt);
|
||||
$result = mysqli_stmt_get_result($stmt);
|
||||
$eventDetails = mysqli_fetch_assoc($result);
|
||||
|
||||
if ($eventDetails) {
|
||||
$eventTitle = $eventDetails["title"];
|
||||
$eventDescription = $eventDetails["description"];
|
||||
$eventType = $eventDetails["event_type"];
|
||||
$eventDate = $eventDetails["date"];
|
||||
$eventLocation = $eventDetails["location"];
|
||||
|
||||
echo "<p class='text'>Vous vous apprêtez à annuler votre participation à l'évènement suivant : </p>";
|
||||
echo "<p class='text'>Nom de l'évènement : $eventTitle</p>";
|
||||
echo "<p class='text'>Date de l'évènement : $eventDate</p>";
|
||||
echo "<p class='text'>Lieu de l'évènement : $eventLocation</p>";
|
||||
echo "<p class='text'>Discipline de l'évènement : $eventType</p>";
|
||||
echo "<p class='text'>Description de l'évènement : $eventDescription</p>";
|
||||
echo "<p class='text'>Adresse mail de l'utilisateur : $userEmail</p>";
|
||||
|
||||
$stmt = mysqli_prepare($db, "DELETE FROM booking WHERE id = ? AND mail = ?");
|
||||
mysqli_stmt_bind_param($stmt, "is", $eventId, $userEmail);
|
||||
if (mysqli_stmt_execute($stmt)) {
|
||||
|
||||
|
||||
echo "<p class='text'>Votre annulation à l'évènement $eventTitle a bien été prise en compte.</p>";
|
||||
|
||||
|
||||
include $_SERVER['DOCUMENT_ROOT'] . '/tools/discordWebhookBooking.php';
|
||||
header("Location: /account/profile/myevents?res=cancellation-succeeded&eventtitle=$eventTitle");
|
||||
} else {
|
||||
echo "<p class='text'>Erreur lors de la mise à jour du nombre de participants.</p>";
|
||||
}
|
||||
} else {
|
||||
echo "<p class='text'>Une erreur est survenue lors de votre annulation à l'évènement. Erreur : " . mysqli_error($db) . "</p>";
|
||||
header("Location: /account/profile/myevents?res=cancellation-failed");
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -1,49 +0,0 @@
|
||||
<?php
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/tools/dbConnect.php';
|
||||
session_start();
|
||||
|
||||
if (isset($_COOKIE['userData'])) {
|
||||
$userDataEncoded = $_COOKIE['userData'];
|
||||
$userData = json_decode($userDataEncoded, true); // 'true' pour obtenir un tableau associatif
|
||||
|
||||
$email = $userData['email'];
|
||||
$name = $userData['name'];
|
||||
$familyName = $userData['familyName'];
|
||||
$role = $userData['role'];
|
||||
}
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link rel="stylesheet" href="/styles/main.css" />
|
||||
<link rel="stylesheet" href="/styles/header.css" />
|
||||
<link rel="stylesheet" href="/styles/footer.css" />
|
||||
<link
|
||||
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
|
||||
<link
|
||||
rel="icon"
|
||||
type="image/png"
|
||||
sizes="32x32"
|
||||
href="https://tickets.paris2024.org/obj/media/FR-Paris2024/specialLogos/favicons/favicon-32x32.png"
|
||||
/>
|
||||
<script
|
||||
src="https://kit.fontawesome.com/f16a36bad3.js"
|
||||
crossorigin="anonymous"
|
||||
></script>
|
||||
<title>Jeux Olympiques - Paris 2024</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php include ($_SERVER['DOCUMENT_ROOT'] . '/views/header.php') ?>
|
||||
|
||||
<!-- code de la page ici -->
|
||||
|
||||
<?php include($_SERVER['DOCUMENT_ROOT'].'/views/footer.php')?>
|
||||
</body>
|
||||
</html>
|
63
events/participate/participate.php
Normal file
63
events/participate/participate.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/tools/dbConnect.php';
|
||||
session_start();
|
||||
|
||||
if (isset($_COOKIE['userData'])) {
|
||||
$userData = json_decode($_COOKIE['userData'], true);
|
||||
|
||||
$email = $userData['email'];
|
||||
$name = $userData['name'];
|
||||
$familyName = $userData['familyName'];
|
||||
$role = $userData['role'];
|
||||
} else {
|
||||
echo "<p class='text'>Vous n'êtes pas autorisé à accéder à cette page.</p>";
|
||||
echo "<p class='text'>Redirection vers l'accueil dans 5 secondes...</p>";
|
||||
header("refresh:5; url=/");
|
||||
die();
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (isset($_GET['usermail']) && isset($_GET['id'])) {
|
||||
$userEmail = $_GET['usermail'];
|
||||
$eventId = $_GET['id'];
|
||||
|
||||
|
||||
|
||||
$stmt = mysqli_prepare($db, "SELECT * FROM event WHERE id = ?");
|
||||
mysqli_stmt_bind_param($stmt, "i", $eventId);
|
||||
mysqli_stmt_execute($stmt);
|
||||
$result = mysqli_stmt_get_result($stmt);
|
||||
$eventDetails = mysqli_fetch_assoc($result);
|
||||
|
||||
if ($eventDetails) {
|
||||
$eventTitle = $eventDetails["title"];
|
||||
$eventDescription = $eventDetails["description"];
|
||||
$eventType = $eventDetails["event_type"];
|
||||
$eventDate = $eventDetails["date"];
|
||||
$eventLocation = $eventDetails["location"];
|
||||
|
||||
echo "<p class='text'>Vous vous apprêtez à participer à l'évènement suivant : </p>";
|
||||
echo "<p class='text'>Nom de l'évènement : $eventTitle</p>";
|
||||
echo "<p class='text'>Date de l'évènement : $eventDate</p>";
|
||||
echo "<p class='text'>Lieu de l'évènement : $eventLocation</p>";
|
||||
echo "<p class='text'>Discipline de l'évènement : $eventType</p>";
|
||||
echo "<p class='text'>Description de l'évènement : $eventDescription</p>";
|
||||
echo "<p class='text'>Adresse mail de l'utilisateur : $userEmail</p>";
|
||||
|
||||
$stmt = mysqli_prepare($db, "INSERT INTO event_entries (id, mail, title, description, event_type, date, location) VALUES (?, ?, ?, ?, ?, ?, ?)");
|
||||
mysqli_stmt_bind_param($stmt, "issssss", $eventId, $userEmail, $eventTitle, $eventDescription, $eventType, $eventDate, $eventLocation);
|
||||
if (mysqli_stmt_execute($stmt)) {
|
||||
echo "<p class='text'>Votre inscription à l'évènement $eventTitle a bien été prise en compte.</p>";
|
||||
header("Location: /account/profile/myentries?res=entry-succeeded");
|
||||
die();
|
||||
} else {
|
||||
echo "<p class='text'>Une erreur est survenue lors de votre inscription à l'évènement. Erreur : " . mysqli_error($db) . "</p>";
|
||||
header("Location: /account/profile/myentries?res=entry-failed");
|
||||
die();
|
||||
}
|
||||
} else {
|
||||
echo "<p class='text'>Évènement introuvable.</p>";
|
||||
}
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user