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'; ?>