<?php
// save_draft.php
require_once '../includes/config.php';

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $student_id = intval($_POST['student_id'] ?? 0);
    $draft_data = json_encode($_POST);
    
    // Save to database or session
    $_SESSION['student_draft_' . $student_id] = $draft_data;
    
    echo json_encode([
        'success' => true,
        'message' => 'Draft saved successfully',
        'timestamp' => date('h:i:s A')
    ]);
}
?>