<?php

session_start();
if(!isset($_SESSION['admin_id']))
{
	header("location:../");
}
require '../connections/conn.php';

$id = $_GET['p_id'];


$check = "SELECT * FROM appointment WHERE p_id='$id'";
$result = $conn->query($check);

if ($result->num_rows > 0) {
   
    echo "❌ Cannot delete: patient has appointment records.";
} else {
   
    $sql = "DELETE FROM patient WHERE p_id='$id'";
    $conn->query($sql);
    header('Location: patient_list.php');
}

?>