<?php
require 'db.php';
require 'helpers.php';
require_committee();

if (!isset($_GET['id']) || !isset($_GET['student_id'])) {
    die('Invalid request');
}

$registration_id = (int)$_GET['id'];
$student_id = $_GET['student_id'];

// Update registration as paid
$stmt = $mysqli1->prepare("UPDATE registrations SET is_paid = 1, updated_at = NOW() WHERE id = ?");
$stmt->bind_param("i", $registration_id);

if ($stmt->execute()) {
    header('Location: committee_student_profile.php?student_id=' . urlencode($student_id) . '&success=1');
} else {
    die('Error updating registration: ' . $mysqli1->error);
}