<?php 
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once '../models/db_connection.php';
require_once '../models/user_model.php';

// Initialize Student object
$student = new User($conn);

// Check if 'id' parameter is set in the URL
if(isset($_GET['id'])) {
    $id = $_GET['id'];
    // Attempt to delete the student record
    $success = $student->deleteUser($id);
        // Redirect to view_students.php with success message
        header("Location: all_users.php?message=Student Deleted successfully");
        exit(); // Ensure no further code execution after redirection
} else {
    // Handle case where 'id' parameter is not set
    echo "Student ID not provided."; // You might want to handle this differently, like redirecting with an error message
    exit(); // Ensure no further code execution if 'id' parameter is missing
}
?>
