<?php
if (!isset($_SESSION['student_id'])) {
    header("Location: ../login/student_login.php");
    exit();
}

$con = mysqli_connect("localhost", "root", "", "WSAS");
$check = mysqli_prepare($con, "SELECT first_login FROM adminstudent WHERE student_id = ?");
mysqli_stmt_bind_param($check, "i", $_SESSION['student_id']);
mysqli_stmt_execute($check);
$result = mysqli_stmt_get_result($check);
$student = mysqli_fetch_assoc($result);

if ($student['first_login'] == 1) {
    $current_page = basename($_SERVER['PHP_SELF']);
    if ($current_page != 'change_pass.php') {
        header("Location: ../login/change_pass.php");
        exit();
    }
}
?>