<?php
session_start();
require_once '../config.php';
if (!isset($_SESSION['role']) || $_SESSION['role'] !== 'kader') { exit; }

$id = $_GET['id'];
// Hapus semua pemeriksaan terkait dulu agar tidak error (Foreign Key)
$pdo->prepare("DELETE FROM pemeriksaan_lansia WHERE id_lansia = ?")->execute([$id]);
// Baru hapus lansianya
$pdo->prepare("DELETE FROM lansia WHERE id_lansia = ?")->execute([$id]);

header("Location: lansia_index.php");