<?php
// Database connection
include './login/connect.php';

// Insert result into the database
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $class_id = $_POST['class_id'];
    $subject_id = $_POST['subject_id'];
    $student_id = $_POST['student_id'];
    $month = $_POST['month'];
    $score = $_POST['score'];

    $stmt = $conn->prepare("INSERT INTO results (class_id, subject_id, student_id, month, score_given) VALUES (?, ?, ?, ?, ?)");
    $stmt->bind_param("iiisi", $class_id, $subject_id, $student_id, $month, $score);

    if ($stmt->execute()) {
        header("Location: result.php?cl==66");
    } else {
        echo "Error: " . $stmt->error;
    }

    $stmt->close();
}

$conn->close();
?>

