From fc1839d4b8184c3140add9b1acf12be9b3cd2a53 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Fri, 5 Dec 2025 19:51:38 +0000 Subject: [PATCH] v1.incomplete2 --- cancel_subscription.php | 34 +++++++++++++++++++ dashboard.php | 17 ++++++++-- includes/header.php | 13 +++++--- profile.php | 72 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 128 insertions(+), 8 deletions(-) create mode 100644 cancel_subscription.php create mode 100644 profile.php diff --git a/cancel_subscription.php b/cancel_subscription.php new file mode 100644 index 0000000..999914e --- /dev/null +++ b/cancel_subscription.php @@ -0,0 +1,34 @@ +prepare("UPDATE user_services SET status = 'cancelled' WHERE id = ? AND user_id = ?"); + $stmt->execute([$user_service_id, $user_id]); + + if ($stmt->rowCount() > 0) { + $_SESSION['message'] = 'Subscription cancelled successfully.'; + } else { + $_SESSION['error'] = 'Could not cancel subscription. It might have been already cancelled or you do not have permission to perform this action.'; + } + } catch (PDOException $e) { + $_SESSION['error'] = 'Database error: ' . $e->getMessage(); + } +} else { + $_SESSION['error'] = 'Invalid request.'; +} + +header('Location: dashboard.php'); +exit; diff --git a/dashboard.php b/dashboard.php index 00b36d9..f640c5e 100644 --- a/dashboard.php +++ b/dashboard.php @@ -9,6 +9,16 @@ require_once 'includes/header.php'; ?>
+ " . $_SESSION['message'] . "
"; + unset($_SESSION['message']); + } + if (isset($_SESSION['error'])) { + echo "
" . $_SESSION['error'] . "
"; + unset($_SESSION['error']); + } + ?>

Welcome to your Dashboard, !

@@ -22,15 +32,16 @@ require_once 'includes/header.php'; prepare("SELECT s.name, s.description FROM services s JOIN user_services us ON s.id = us.service_id WHERE us.user_id = ? AND us.status = 'active'"); + $stmt = $pdo->prepare("SELECT s.name, s.description, us.id as user_service_id FROM services s JOIN user_services us ON s.id = us.service_id WHERE us.user_id = ? AND us.status = 'active'"); $stmt->execute([$_SESSION['user_id']]); $user_services = $stmt->fetchAll(PDO::FETCH_ASSOC); if (count($user_services) > 0) { echo "
    "; foreach ($user_services as $service) { - echo "
  • "; - echo "" . htmlspecialchars($service['name']) . ": " . htmlspecialchars($service['description']); + echo "
  • "; + echo "
    " . htmlspecialchars($service['name']) . ": " . htmlspecialchars($service['description']) . "
    "; + echo "Cancel"; echo "
  • "; } echo "
"; diff --git a/includes/header.php b/includes/header.php index 49176af..dc673f5 100644 --- a/includes/header.php +++ b/includes/header.php @@ -68,11 +68,14 @@ - -