Go to main navigation Skip to content

School Management System Project With Source Code In Php

$query = "SELECT * FROM students"; $result = mysqli_query($conn, $query);

?>

-- 7. Exam marks table CREATE TABLE exam_marks ( id INT(11) AUTO_INCREMENT PRIMARY KEY, student_id INT(11), subject_id INT(11), marks_obtained INT(11), exam_name VARCHAR(50) -- e.g., Midterm, Final FOREIGN KEY (student_id) REFERENCES students(id), FOREIGN KEY (subject_id) REFERENCES subjects(id) );

: Modify your project's db_config.php file to include matching credentials:

<?php session_start(); if (!isset($_SESSION['admin'])) header('Location: ../login.php'); exit(); school management system project with source code in php

<h2>My Exam Results</h2> <table border="1"> <tr><th>Subject</th><th>Exam</th><th>Marks</th></tr> <?php while($row = mysqli_fetch_assoc($result)) ?> <tr> <td><?php echo $row['subject_name']; ?></td> <td><?php echo $row['exam_name']; ?></td> <td><?php echo $row['marks_obtained']; ?></td> </tr> <?php ?> </table>

if(isset($_POST['save_attendance'])) $date = $_POST['attendance_date']; $class_id = $_POST['class_id'];

Getting a PHP project up and running on your local machine is straightforward. Follow this general guide applicable to almost any of the GitHub repositories listed later.

: Extract your project source files into the root directory (e.g., C:/xampp/htdocs/school_system/ ). Configure the Database : $query = "SELECT * FROM students"; $result =

prepare("SELECT * FROM users WHERE username = ?"); $stmt->execute([$username]); $user = $stmt->fetch(); if ($user && password_verify($password, $user['password'])) $_SESSION['user_id'] = $user['id']; $_SESSION['role'] = $user['role']; // Redirect based on role header("Location: dashboards/" . $user['role'] . "_dashboard.php"); exit; else $error = "Invalid username or password."; ?> Use code with caution. Step 3: Attendance Logging Interface ( mark_attendance.php )

prepare('SELECT * FROM users WHERE username = ?'); $stmt->execute([$username]); $user = $stmt->fetch(); // Verify hashed password if ($user && password_verify($password, $user['password'])) $_SESSION['user_id'] = $user['id']; $_SESSION['role'] = $user['role']; $_SESSION['username'] = $user['username']; // Redirect based on user role switch ($user['role']) case 'admin': header('Location: admin_dashboard.php'); break; case 'teacher': header('Location: teacher_dashboard.php'); break; case 'student': header('Location: student_dashboard.php'); break; exit; else $error = "Invalid username or password."; else $error = "Please fill in all fields."; ?> System Login

A standard school ecosystem requires strict Role-Based Access Control (RBAC). The system segments privileges into four unique user dashboards: 1. Super Administrator (Admin) Manages user creation (Teachers, Students, Parents).

Create a database named school_db . The following SQL script sets up the core tables. : Extract your project source files into the

: Always sanitize user inputs and use prepared statements in production to prevent SQL injection.

function require_role($role)

A relational database structure ensures data integrity. Use this optimized database schema to kickstart your database configuration.

prepare($sql)) $stmt->bindParam(":username", $username, PDO::PARAM_STR); if ($stmt->execute()) if ($stmt->rowCount() == 1) if ($row = $stmt->fetch()) if (password_verify($password, $row['password'])) $_SESSION["loggedin"] = true; $_SESSION["id"] = $row['id']; $_SESSION["role"] = $row['role']; // Redirect based on role header("location: dashboards/" . $row['role'] . "_dashboard.php"); exit; ?> Use code with caution. 3. Student Attendance Logger ( mark_attendance.php )