Mini Kabibi Habibi
<?php
session_start();
@include 'include/config.php';
if (!isset($_SESSION['username_school'])) {
header('Location: login.php');
exit();
}
if (isset($_GET['plan_id'])) {
$plan_id = $_GET['plan_id'];
$username = $_SESSION['username_school'];
// Check if the MISTA plan exists for this user
$checkPlanQuery = $conn->prepare("SELECT * FROM mista_plans WHERE id = ? AND username = ?");
$checkPlanQuery->bind_param("is", $plan_id, $username);
$checkPlanQuery->execute();
$result = $checkPlanQuery->get_result();
if ($result->num_rows > 0) {
// Plan exists, now delete it
$deleteQuery = $conn->prepare("DELETE FROM mista_plans WHERE id = ? AND username = ?");
$deleteQuery->bind_param("is", $plan_id, $username);
if ($deleteQuery->execute()) {
// Redirect back to the plans page after successful deletion
header("Location: view_mista_plans.php?msg=deleted");
exit();
} else {
echo "Error: Could not delete the plan.";
}
} else {
echo "Error: Plan not found or does not belong to this user.";
}
} else {
echo "Error: Plan ID is missing.";
}
?>