<?php
require 'config.php';

if(isset($_POST['id'], $_POST['status'])) {
    $id = (int) $_POST['id'];
    $status = $_POST['status'];

    // ✅ now includes 'active'
    if(!in_array($status, ['active','suspended','withdrawn'])) {
        exit("Invalid status");
    }

    // Use your DB handle ($dbh from config.php)
    $stmt = $dbh->prepare("UPDATE students SET status=? WHERE id=?");
    if($stmt->execute([$status, $id])) {
        echo "Student updated to $status successfully!";
    } else {
        echo "Failed to update.";
    }
}
