School Management System Project With Source Code In Php
CREATE DATABASE school_management; USE school_management; -- 1. Admins table CREATE TABLE admins ( id INT(11) AUTO_INCREMENT PRIMARY KEY, username VARCHAR(50) NOT NULL UNIQUE, password VARCHAR(255) NOT NULL, email VARCHAR(100), created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP );
// Fetch classes for dropdown $class_result = mysqli_query($conn, "SELECT * FROM classes"); ?> <form method="post"> <input type="text" name="student_name" placeholder="Full Name" required> <input type="text" name="roll_no" placeholder="Roll Number" required> <select name="class_id"> <?php while($row = mysqli_fetch_assoc($class_result)) ?> <option value="<?php echo $row['id']; ?>"><?php echo $row['class_name'] . " " . $row['section']; ?></option> <?php ?> </select> <input type="text" name="parent_mobile" placeholder="Parent Mobile"> <input type="password" name="password" placeholder="Default Password"> <button type="submit" name="submit">Add Student</button> </form> <?php session_start(); if (!isset($_SESSION['teacher_id'])) header('Location: ../login.php'); exit(); school management system project with source code in php
if ($role == 'admin') $query = "SELECT * FROM admins WHERE username='$username' AND password='$password'"; $result = mysqli_query($conn, $query); if (mysqli_num_rows($result) == 1) $_SESSION['admin'] = $username; header('Location: admin/dashboard.php'); elseif ($role == 'teacher') $query = "SELECT * FROM teachers WHERE email='$username' AND password='$password'"; $result = mysqli_query($conn, $query); if (mysqli_num_rows($result) == 1) $row = mysqli_fetch_assoc($result); $_SESSION['teacher_id'] = $row['id']; header('Location: teacher/dashboard.php'); elseif ($role == 'student') $query = "SELECT * FROM students WHERE roll_no='$username' AND password='$password'"; $result = mysqli_query($conn, $query); if (mysqli_num_rows($result) == 1) $row = mysqli_fetch_assoc($result); $_SESSION['student_id'] = $row['id']; header('Location: student/dashboard.php'); $row['section'];
?> <!-- HTML Form here --> <form method="post"> <input type="text" name="username" placeholder="Username/Roll No/Email"> <input type="password" name="password"> <select name="role"> <option value="admin">Admin</option> <option value="teacher">Teacher</option> <option value="student">Student</option> </select> <button type="submit">Login</button> </form> <?php session_start(); if (!isset($_SESSION['admin'])) header('Location: ../login.php'); exit(); button type="submit" name="submit">
include('../config/db_connection.php'); if (isset($_POST['submit'])) $name = $_POST['student_name']; $roll = $_POST['roll_no']; $class_id = $_POST['class_id']; $mobile = $_POST['parent_mobile']; $password = md5($_POST['password']);