$allowed_roles = ['admin', 'teacher', 'student', 'parent']; if (!in_array($_SESSION['role'], $allowed_roles)) die("Unauthorized access.");
?> File: modules/admin/add_student.php
<?php require_once '../../config/database.php'; require_once '../../includes/auth.php'; if ($_SERVER['REQUEST_METHOD'] == 'POST') // Insert into users table first $username = $_POST['admission_no']; $hashed_password = password_hash($_POST['password'], PASSWORD_DEFAULT); $role = 'student'; school management system project with source code in php
Most educational PHP projects are open-source under the MIT or GPL license. Check the license file included. $allowed_roles = ['admin'