<?php
$con = mysqli_connect("localhost", "root", "", "WSAS");

if (!$con) {
    die("Connection failed: " . mysqli_connect_error());
}

if (isset($_POST['submit'])) {

    $student_id = $_POST['student_id'];
    $subject_id = $_POST['subject_id'];
    $subject_status = $_POST['subject_status'];

    $sql = "INSERT INTO student_subject 
            (student_id, subject_id, subject_status)
            VALUES 
            ('$student_id', '$subject_id', '$subject_status')";

    if (mysqli_query($con, $sql)) {
        header("Location: ../adminpanel/adminstudents.php?success=1");
        exit();
    } else {
        echo "Error: " . mysqli_error($con);
    }
}

mysqli_close($con);
?>
