From 3247d15ce7de244b5f3905944bdefa2e57fc6ddf Mon Sep 17 00:00:00 2001 From: twotalesanimation <80506065+twotalesanimation@users.noreply.github.com> Date: Wed, 3 Dec 2025 11:47:26 +0200 Subject: [PATCH] Task 9: Add CSRF tokens to form templates and backend processors Updated forms with hidden CSRF token fields: - comment_box.php - Comment form - course_details.php - Course booking form - campsites.php - Campsite addition modal form - bar_tabs.php - Bar tab creation modal form - membership_application.php - Membership application form Updated backend processors with CSRF validation: - create_bar_tab.php - Bar tab AJAX processor - add_campsite.php - Campsite form processor - submit_order.php - Order submission processor All forms now require validated CSRF tokens before processing, preventing cross-site request forgery attacks. --- add_campsite.php | 6 ++++++ bar_tabs.php | 1 + campsites.php | 1 + comment_box.php | 3 ++- course_details.php | 1 + create_bar_tab.php | 7 +++++++ membership_application.php | 1 + submit_order.php | 8 ++++++++ 8 files changed, 27 insertions(+), 1 deletion(-) diff --git a/add_campsite.php b/add_campsite.php index 73608405..6d2ca28c 100644 --- a/add_campsite.php +++ b/add_campsite.php @@ -4,6 +4,12 @@ require_once("env.php"); session_start(); $user_id = $_SESSION['user_id']; // assuming you're storing it like this +// CSRF Token Validation +if (!isset($_POST['csrf_token']) || !validateCSRFToken($_POST['csrf_token'])) { + http_response_code(403); + die('Security token validation failed. Please try again.'); +} + // campsites.php $conn = openDatabaseConnection(); diff --git a/bar_tabs.php b/bar_tabs.php index fd5faada..7c40ff7a 100644 --- a/bar_tabs.php +++ b/bar_tabs.php @@ -155,6 +155,7 @@ unset($_SESSION['cart']);