real_escape_string($_POST['eventName']); $eventDate = $db->real_escape_string($_POST['eventDate']); $eventLocation = $db->real_escape_string($_POST['eventLocation']); $eventDiscipline = $db->real_escape_string($_POST['eventDiscipline']); $eventDescription = $db->real_escape_string($_POST['eventDescription']); $eventRoles = isset($_POST['eventRole']) ? $_POST['eventRole'] : []; $rolesText = implode(', ', $eventRoles); if (isset($_COOKIE['userData'])) { $userDataEncoded = $_COOKIE['userData']; $userData = json_decode($userDataEncoded, true); $email = $userData['email']; $name = $userData['name']; $familyName = $userData['familyName']; $role = $userData['role']; } echo "
Nom de l'évènement : $eventName
"; echo "Date de l'évènement : $eventDate
"; echo "Lieu de l'évènement : $eventLocation
"; echo "Discipline de l'évènement : $eventDiscipline
"; echo "Description de l'évènement : $eventDescription
"; echo "Rôles de l'évènement : $rolesText
"; echo "Créateur de l'évènement : $email
"; $stmt = mysqli_prepare($db, "INSERT INTO `event` (title, description, event_type, date, location, role, guest_count, creator) VALUES (?, ?, ?, ?, ?, ?, 0, ?)"); mysqli_stmt_bind_param($stmt, 'sssssss', $eventName, $eventDescription, $eventDiscipline, $eventDate, $eventLocation, $rolesText, $email); $result = mysqli_stmt_execute($stmt); if ($result) { echo "L'évènement a bien été créé.
"; include ($_SERVER['DOCUMENT_ROOT'] . '/tools/discordWebhookNewEvent.php'); header("Location: /events/new?result=event-creation-succeded"); } else { echo "Une erreur est survenue lors de la création de l'évènement. Erreur : " . mysqli_error($db) . "
"; header("Location: /events/new?result=event-creation-failed"); } } else { echo "Veuillez remplir tous les champs du formulaire.
"; } ?>