<?php 
session_start();
include '../connection.php';

if (isset($_SESSION['resident_id'])) {
	$id = $_SESSION['resident_id']; // ✅ Get the ID before unsetting
	unset($_SESSION['resident_id']);
	
	// Optional: destroy full session if needed
	// session_destroy();
	
	// Update status in database
	$query = "UPDATE `tbl_resident` SET `status` = '0' WHERE `resident_id` = '$id'";
	$query_result = $conn->query($query);
	
	// Redirect to homepage
	header("Location: ../index.php");
	exit();
}
?>
