<?php
// --- DB connection ---
$host = "localhost";
$username = "rangamatiahighsc_boueduUser";
$password = "@@Jakir@@#321";
$database = "rangamatiahighsc_boueduDb";

$conn = mysqli_connect($host, $username, $password, $database);
if (!$conn) {
    die("Database connection failed.");
}

// --- Check POST input ---
if (isset($_POST['studentId'])) {
    $studentId = mysqli_real_escape_string($conn, trim($_POST['studentId']));

    // Optional format validation (if needed)
    if (!preg_match('/^[A-Za-z0-9]+$/', $studentId)) {
        echo "<div class='text-red-600'>Invalid Student ID.</div>";
        exit;
    }

    $query = "SELECT * FROM `student` WHERE `student_id` = '$studentId'";
    $result = mysqli_query($conn, $query);

    if (mysqli_num_rows($result) > 0) {
        $row = mysqli_fetch_assoc($result);
        $studentData = $row;
        $progrName = $row['course_nama'];
        if($progrName === "ssc"){
          
            include "ssc_result.php";
        }else if($progrName === "hsc"){
            include "hsc_result.php";
            
        }else if($progrName === "bba"){
            include "bba_result.php";
            
        }else if($progrName === "mba"){
            include "mba_result.php";
            
        }else if($progrName === "ronimiya"){
            include "roni_result.php";
            
        }else if($progrName === "emon"){
            include "emon_result.php";
            
        }else if($progrName === "Dadasishroy"){
            include "Dadasishroy.php";
            
        }else if($progrName === "murtoza"){
            include "mortoza_result.php";
            
        }

        
    } else {
        echo "<div class='bg-red-100 border border-red-400 text-red-800 px-4 py-3 rounded'>No result found for this Student ID.</div>";
    }
} else {
    echo "<div class='bg-yellow-100 border border-yellow-400 text-yellow-800 px-4 py-3 rounded'>Student ID not provided.</div>";
}

mysqli_close($conn);
?>

