School Management Systems (SMS) is a web application that commonly used in schools to manage teachers, students, classes, subjects, sections, students attendance etc.

So if you’re a PHP developer and wants to develop School Management System with PHP then you’re here at right place. In our previous tutorial you have learned how to develop online voting system with PHP and MYSQL. In this tutorial you will learn how to develop a School Management System with PHP and MySQL.

We will cover this tutorial in easy steps to develop live demo of school management systems to cover some major functionalities like manage teachers, students, classes, subjects, sections, students attendance etc. .

Features

  • So let’s start implementing School Management System with PHP and MySQL. Before we begin, take a look on files structure for this example. index.php School.php: A class to hold school methods. dashboard.php students.php teacher.php classes.php subjects.php sections.php attendance.php Step1: Create MySQL Database Table First we will MySQL database tables sms_user, sms_teacher, sms_students, sms_classes, sms_subjects, sms_section and sms_attendance. All the tables structure and data is available in project download zip file. Step2: Create User Login In index.php file, we will create login form to implement admin login to allow access to logged in user only. <div class="container"> <div class="col-md-6"> <div class="panel panel-info"> <div class="panel-heading" style="background:#000;color:white;"> <div class="panel-title">Admin Login</div> </div> <div style="padding-top:30px" class="panel-body" > <?php if ($errorMessage != '') { ?> <div id="login-alert" class="alert alert-danger col-sm-12"><?php echo $errorMessage; ?></div> <?php } ?> <form id="loginform" class="form-horizontal" role="form" method="POST" action=""> <div style="margin-bottom: 25px" class="input-group"> <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span> <input type="text" class="form-control" id="email" name="email" placeholder="email" required> </div> <div style="margin-bottom: 25px" class="input-group"> <span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span> <input type="password" class="form-control" id="password" name="password" placeholder="password" required> </div> <div style="margin-top:10px" class="form-group"> <div class="col-sm-12 controls"> <input type="submit" name="login" value="Login" class="btn btn-success"> </div> </div> <div style="margin-top:10px" class="form-group"> <div class="col-sm-12 controls"> Admin: admin@webdamn.com<br> password:123 <br><br> </div> </div> </form> </div> </div> </div> We will implement user login on login form submit by calling method adminLogin() from class School.php include('class/School.php'); $school = new School(); $school->adminLogin(); In class School.php, we will implement method adminLogin(). public function adminLogin(){ $errorMessage = ''; if(!empty($_POST["login"]) && $_POST["email"]!=''&& $_POST["password"]!='') { $email = $_POST['email']; $password = $_POST['password']; $sqlQuery = "SELECT * FROM ".$this->userTable." WHERE email='".$email."' AND password='".md5($password)."' AND status = 'active' AND type = 'administrator'"; $resultSet = mysqli_query($this->dbConnect, $sqlQuery) or die("error".mysql_error()); $isValidLogin = mysqli_num_rows($resultSet); if($isValidLogin){ $userDetails = mysqli_fetch_assoc($resultSet); $_SESSION["adminUserid"] = $userDetails['id']; $_SESSION["admin"] = $userDetails['first_name']." ".$userDetails['last_name']; header("location: dashboard.php"); } else { $errorMessage = "Invalid login!"; } } else if(!empty($_POST["login"])){ $errorMessage = "Enter Both user and password!"; } return $errorMessage; } Step3: Manage Teachers Section In teacher.php file, we will create design to add new teacher details edit and display teacher list. <div class="content"> <div class="container-fluid"> <div> <a href="#"><strong><span class="ti-crown"></span> Teachers Section</strong></a> <hr> <div class="panel-heading"> <div class="row"> <div class="col-md-10"> <h3 class="panel-title"></h3> </div> <div class="col-md-2" align="right"> <button type="button" name="add" id="addTeacher" class="btn btn-success btn-xs">Add New Teacher</button> </div> </div> </div> <table id="teacherList" class="table table-bordered table-striped"> <thead> <tr> <th>ID</th> <th>Name</th> <th>Assigned Subjects</th> <th>Class</th> <th>Sections</th> <th></th> <th></th> </tr> </thead> </table> </div> </div> </div> We will call School class methods addTeacher(), updateTeacher and listTeacher() to handle teachers functionality. public function listTeacher(){ $sqlQuery = "SELECT t.teacher_id, t.teacher, s.subject, c.name, se.section FROM ".$this-<teacherTable." as t LEFT JOIN ".$this-<subjectsTable." as s ON t.subject_id = s.subject_id LEFT JOIN ".$this-<classesTable." as c ON t.teacher_id = c.teacher_id LEFT JOIN ".$this-<sectionsTable." as se ON c.section = se.section_id "; if(!empty($_POST["search"]["value"])){ $sqlQuery .= ' WHERE (t.teacher_id LIKE "%'.$_POST["search"]["value"].'%" '; $sqlQuery .= ' OR t.teacher LIKE "%'.$_POST["search"]["value"].'%" '; } if(!empty($_POST["order"])){ $sqlQuery .= 'ORDER BY '.$_POST['order']['0']['column'].' '.$_POST['order']['0']['dir'].' '; } else { $sqlQuery .= 'ORDER BY t.teacher_id DESC '; } if($_POST["length"] != -1){ $sqlQuery .= 'LIMIT ' . $_POST['start'] . ', ' . $_POST['length']; } $result = mysqli_query($this-<dbConnect, $sqlQuery); $numRows = mysqli_num_rows($result); $teacherData = array(); while( $teacher = mysqli_fetch_assoc($result) ) { $teacherRows = array(); $teacherRows[] = $teacher['teacher_id']; $teacherRows[] = $teacher['teacher']; $teacherRows[] = $teacher['subject']; $teacherRows[] = $teacher['name']; $teacherRows[] = $teacher['section']; $teacherRows[] = '>button type="button" name="update" id="'.$teacher["teacher_id"].'" class="btn btn-warning btn-xs update"<Update>/button<'; $teacherRows[] = '>button type="button" name="delete" id="'.$teacher["teacher_id"].'" class="btn btn-danger btn-xs delete" <Delete>/button<'; $teacherData[] = $teacherRows; } $output = array( "draw" =< intval($_POST["draw"]), "recordsTotal" =< $numRows, "recordsFiltered" =< $numRows, "data" =< $teacherData ); echo json_encode($output); } Step4: Manage Student Sections In students.php file, we will design to display student list, save new student admission, update and delete student details. <div class="content"> <div class="container-fluid"> <div> <a href="#"><strong><span class="ti-crown"></span> Student Section</strong></a> <hr> <div class="panel-heading"> <div class="row"> <div class="col-md-10"> <h3 class="panel-title"></h3> </div> <div class="col-md-2" align="right"> <button type="button" name="add" id="addStudent" class="btn btn-success btn-xs">Student Admission</button> </div> </div> </div> <table id="studentList" class="table table-bordered table-striped"> <thead> <tr> <th>ID</th> <th>Reg No</th> <th>Roll No</th> <th>Name</th> <th>Photo</th> <th>Class</th> <th>Section</th> <th></th> <th></th> </tr> </thead> </table> </div> </div> </div> We will call School class methods addStudent(), updateStudent, deleteStudent and listStudent() to handle teachers functionality. public function listStudent(){ $sqlQuery = "SELECT s.id, s.name, s.photo, s.gender, s.dob, s.mobile, s.email, s.current_address, s.father_name, s.mother_name,s.admission_no, s.roll_no, s.admission_date, s.academic_year, c.name as class, se.section FROM ".$this->studentTable." as s LEFT JOIN ".$this->classesTable." as c ON s.class = c.id LEFT JOIN ".$this->sectionsTable." as se ON s.section = se.section_id "; if(!empty($_POST["search"]["value"])){ $sqlQuery .= ' WHERE (s.id LIKE "%'.$_POST["search"]["value"].'%" '; $sqlQuery .= ' OR s.name LIKE "%'.$_POST["search"]["value"].'%" '; $sqlQuery .= ' OR s.gender LIKE "%'.$_POST["search"]["value"].'%" '; $sqlQuery .= ' OR s.mobile LIKE "%'.$_POST["search"]["value"].'%" '; $sqlQuery .= ' OR s.admission_no LIKE "%'.$_POST["search"]["value"].'%" '; $sqlQuery .= ' OR s.roll_no LIKE "%'.$_POST["search"]["value"].'%" '; } if(!empty($_POST["order"])){ $sqlQuery .= 'ORDER BY '.$_POST['order']['0']['column'].' '.$_POST['order']['0']['dir'].' '; } else { $sqlQuery .= 'ORDER BY s.id DESC '; } if($_POST["length"] != -1){ $sqlQuery .= 'LIMIT ' . $_POST['start'] . ', ' . $_POST['length']; } $result = mysqli_query($this->dbConnect, $sqlQuery); $numRows = mysqli_num_rows($result); $studentData = array(); while( $student = mysqli_fetch_assoc($result) ) { $studentRows = array(); $studentRows[] = $student['id']; $studentRows[] = $student['admission_no']; $studentRows[] = $student['roll_no']; $studentRows[] = $student['name']; $studentRows[] = "<img width='40' height='40' src='upload/".$student['photo']."'>"; $studentRows[] = $student['class']; $studentRows[] = $student['section']; $studentRows[] = '<button type="button" name="update" id="'.$student["id"].'" class="btn btn-warning btn-xs update">Update</button>'; $studentRows[] = '<button type="button" name="delete" id="'.$student["id"].'" class="btn btn-danger btn-xs delete" >Delete</button>'; $studentData[] = $studentRows; } $output = array( "draw" => intval($_POST["draw"]), "recordsTotal" => $numRows, "recordsFiltered" => $numRows, "data" => $studentData ); echo json_encode($output); } Step5: Manage Classes Section In classes.php file, we will design HTML to handle classes functionality like create class, update class, delete class and list classes. <div class="content"> <div class="container-fluid"> <div> <a href="#"><strong><span class="ti-crown"></span> Classes Section</strong></a> <hr> <div class="panel-heading"> <div class="row"> <div class="col-md-10"> <h3 class="panel-title"></h3> </div> <div class="col-md-2" align="right"> <button type="button" name="add" id="addClass" class="btn btn-success btn-xs">Add New Class</button> </div> </div> </div> <table id="classList" class="table table-bordered table-striped"> <thead> <tr> <th>ID</th> <th>Name</th> <th>Sections</th> <th>Class Teacher</th> <th></th> <th></th> </tr> </thead> </table> </div> </div> </div> We will call School class methods addClass(), updateClass, deleteClass and listClasses() to handle classes functionality. public function listClasses(){ $sqlQuery = "SELECT c.id, c.name, s.section, t.teacher FROM ".$this->classesTable." as c LEFT JOIN ".$this->sectionsTable." as s ON c.section = s.section_id LEFT JOIN ".$this->teacherTable." as t ON c.teacher_id = t.teacher_id "; if(!empty($_POST["search"]["value"])){ $sqlQuery .= ' WHERE (c.id LIKE "%'.$_POST["search"]["value"].'%" '; $sqlQuery .= ' OR c.name LIKE "%'.$_POST["search"]["value"].'%" '; $sqlQuery .= ' OR s.section LIKE "%'.$_POST["search"]["value"].'%" '; $sqlQuery .= ' OR t.teacher LIKE "%'.$_POST["search"]["value"].'%" '; } if(!empty($_POST["order"])){ $sqlQuery .= 'ORDER BY '.$_POST['order']['0']['column'].' '.$_POST['order']['0']['dir'].' '; } else { $sqlQuery .= 'ORDER BY c.id DESC '; } if($_POST["length"] != -1){ $sqlQuery .= 'LIMIT ' . $_POST['start'] . ', ' . $_POST['length']; } $result = mysqli_query($this->dbConnect, $sqlQuery); $numRows = mysqli_num_rows($result); $classesData = array(); while( $classes = mysqli_fetch_assoc($result) ) { $classesRows = array(); $classesRows[] = $classes['id']; $classesRows[] = $classes['name']; $classesRows[] = $classes['section']; $classesRows[] = $classes['teacher']; $classesRows[] = '<button type="button" name="update" id="'.$classes["id"].'" class="btn btn-warning btn-xs update">Update</button>'; $classesRows[] = '<button type="button" name="delete" id="'.$classes["id"].'" class="btn btn-danger btn-xs delete" >Delete</button>'; $classesData[] = $classesRows; } $output = array( "draw" => intval($_POST["draw"]), "recordsTotal" => $numRows, "recordsFiltered" => $numRows, "data" => $classesData ); echo json_encode($output); } Step6: Manage Subjects Section In subjects.php file, we will design page to handle functionality to add new subjects, update, delete and list subjects. <div class="content"> <div class="container-fluid"> <div> <a href="#"><strong><span class="ti-crown"></span> Subjects Section</strong></a> <hr> <div class="panel-heading"> <div class="row"> <div class="col-md-10"> <h3 class="panel-title"></h3> </div> <div class="col-md-2" align="right"> <button type="button" name="add" id="addSubject" class="btn btn-success btn-xs">Add New Subject</button> </div> </div> </div> <table id="subjectList" class="table table-bordered table-striped"> <thead> <tr> <th>ID</th> <th>Subject</th> <th>Code</th> <th>Subject Type</th> <th></th> <th></th> </tr> </thead> </table> </div> </div> </div> We will call School class methods addSubject(), updateSubject, deleteSubject and listSubject() to handle Subjects functionality. public function listSubject(){ $sqlQuery = "SELECT subject_id, subject, type, code FROM ".$this->subjectsTable." "; if(!empty($_POST["search"]["value"])){ $sqlQuery .= ' WHERE (subject_id LIKE "%'.$_POST["search"]["value"].'%" '; $sqlQuery .= ' OR subject LIKE "%'.$_POST["search"]["value"].'%" '; $sqlQuery .= ' OR type LIKE "%'.$_POST["search"]["value"].'%" '; $sqlQuery .= ' OR code LIKE "%'.$_POST["search"]["value"].'%" '; } if(!empty($_POST["order"])){ $sqlQuery .= 'ORDER BY '.$_POST['order']['0']['column'].' '.$_POST['order']['0']['dir'].' '; } else { $sqlQuery .= 'ORDER BY subject_id DESC '; } if($_POST["length"] != -1){ $sqlQuery .= 'LIMIT ' . $_POST['start'] . ', ' . $_POST['length']; } $result = mysqli_query($this->dbConnect, $sqlQuery); $numRows = mysqli_num_rows($result); $subjectData = array(); while( $subject = mysqli_fetch_assoc($result) ) { $subjectRows = array(); $subjectRows[] = $subject['subject_id']; $subjectRows[] = $subject['subject']; $subjectRows[] = $subject['code']; $subjectRows[] = $subject['type']; $subjectRows[] = '<button type="button" name="update" id="'.$subject["subject_id"].'" class="btn btn-warning btn-xs update">Update</button>'; $subjectRows[] = '<button type="button" name="delete" id="'.$subject["subject_id"].'" class="btn btn-danger btn-xs delete" >Delete</button>'; $subjectData[] = $subjectRows; } $output = array( "draw" => intval($_POST["draw"]), "recordsTotal" => $numRows, "recordsFiltered" => $numRows, "data" => $subjectData ); echo json_encode($output); } Step7: Manage Student Attendance Section In attendance.php file, we will design HTML to search class and section student attendance and list. We will also create student attendance form to handle students attendance functionality. <div class="content"> <div class="container-fluid"> <strong>Student Attendance Section</strong> <div class="row"> <div class="col-md-12"> <div class="box box-primary"> <div class="box-header with-border"> <h3 class="box-title"><i class="fa fa-search"></i> Select Criteria</h3> </div> <form id="form1" action="" method="post" accept-charset="utf-8"> <div class="box-body"> <div class="row"> <div class="col-md-4"> <div class="form-group"> <label for="exampleInputEmail1">Class</label><small class="req"> *</small> <select id="classid" name="classid" class="form-control" required> <option value="">Select</option> <?php echo $school->classList(); ?> </select> <span class="text-danger"></span> </div> </div> <div class="col-md-4"> <div class="form-group"> <label for="exampleInputEmail1">Section</label><small class="req"> *</small> <select name="sectionid" id="sectionid" class="form-control" required> <option value="">Select</option> <?php echo $school->getSectionList(); ?> </select> <span class="text-danger"></span> </div> </div> </div> </div> <div class="box-footer"> <button type="button" id="search" name="search" value="search" style="margin-bottom:10px;" class="btn btn-primary btn-sm checkbox-toggle"><i class="fa fa-search"></i> Search</button> <br> </div> </form> </div> </div> </div> <div class="row"> <form id="attendanceForm" method="post"> <div style="color:red;margin-top:20px;" class="hidden" id="message"></div> <button type="submit" id="saveAttendance" name="saveAttendance" value="Save Attendance" style="margin-bottom:10px;" class="btn btn-primary btn-sm pull-right checkbox-toggle hidden"><i class="fa fa-save"></i> Save Attendance</button> <table id="studentList" class="table table-bordered table-striped hidden"> <thead> <tr> <th>#</th> <th>Reg No</th> <th>Roll No</th> <th>Name</th> <th>Attendance</th> </tr> </thead> </table> <input type="hidden" name="action" id="action" value="updateAttendance" /> <input type="hidden" name="att_classid" id="att_classid" value="" /> <input type="hidden" name="att_sectionid" id="att_sectionid" value="" /> </form> </div> </div> We will implement class section student serach functionality to perform student attendance. $('#search').click(function(){ $('#studentList').removeClass('hidden'); $('#saveAttendance').removeClass('hidden'); if ($.fn.DataTable.isDataTable("#studentList")) { $('#studentList').DataTable().clear().destroy(); } var classid = $('#classid').val(); var sectionid = $('#sectionid').val(); if(classid && sectionid) { $.ajax({ url:"action.php", method:"POST", data:{classid:classid, sectionid:sectionid, action:"attendanceStatus"}, success:function(data) { $('#message').text(data).removeClass('hidden'); } }) $('#studentList').DataTable({ "lengthChange": false, "processing":true, "serverSide":true, "order":[], "ajax":{ url:"action.php", type:"POST", data:{classid:classid, sectionid:sectionid, action:'getStudents'}, dataType:"json" }, "columnDefs":[ { "targets":[0], "orderable":false, }, ], "pageLength": 10 }); } }); We will also implement students attendance functionality bu handle form submit. $("#attendanceForm").submit(function(e) { var formData = $(this).serialize(); $.ajax({ url:"action.php", method:"POST", data:formData, success:function(data){ $('#message').text(data).removeClass('hidden'); } }); return false; }); We will handle student attendance update functionality by calling method updateAttendance() from class School.php. public function updateAttendance(){ $attendanceYear = date('Y'); $attendanceMonth = date('m'); $attendanceDay = date('d'); $attendanceDate = $attendanceYear."/".$attendanceMonth."/".$attendanceDay; $sqlQuery = "SELECT * FROM ".$this->attendanceTable." WHERE class_id = '".$_POST["att_classid"]."' AND section_id = '".$_POST["att_sectionid"]."' AND attendance_date = '".$attendanceDate."'"; $result = mysqli_query($this->dbConnect, $sqlQuery); $attendanceDone = mysqli_num_rows($result); if($attendanceDone) { foreach($_POST as $key => $value) { if (strpos($key, "attendencetype_") !== false) { $student_id = str_replace("attendencetype_","", $key); $attendanceStatus = $value; if($student_id) { $updateQuery = "UPDATE ".$this->attendanceTable." SET attendance_status = '".$attendanceStatus."' WHERE student_id = '".$student_id."' AND class_id = '".$_POST["att_classid"]."' AND section_id = '".$_POST["att_sectionid"]."' AND attendance_date = '".$attendanceDate."'"; mysqli_query($this->dbConnect, $updateQuery); } } } echo "Attendance updated successfully!"; } else { foreach($_POST as $key => $value) { if (strpos($key, "attendencetype_") !== false) { $student_id = str_replace("attendencetype_","", $key); $attendanceStatus = $value; if($student_id) { $insertQuery = "INSERT INTO ".$this->attendanceTable."(student_id, class_id, section_id, attendance_status, attendance_date) VALUES ('".$student_id."', '".$_POST["att_classid"]."', '".$_POST["att_sectionid"]."', '".$attendanceStatus."', '".$attendanceDate."')"; mysqli_query($this->dbConnect, $insertQuery); } } } echo "Attendance save successfully!"; } }

Project Activity

See All Activity >

Follow SchoolManagementSystem-Web-Template

SchoolManagementSystem-Web-Template Web Site

You Might Also Like
Red Hat Enterprise Linux on Microsoft Azure Icon
Red Hat Enterprise Linux on Microsoft Azure

Deploy Red Hat Enterprise Linux on Microsoft Azure for a secure, reliable, and scalable cloud environment, fully integrated with Microsoft services.

Red Hat Enterprise Linux (RHEL) on Microsoft Azure provides a secure, reliable, and flexible foundation for your cloud infrastructure. Red Hat Enterprise Linux on Microsoft Azure is ideal for enterprises seeking to enhance their cloud environment with seamless integration, consistent performance, and comprehensive support.
Rate This Project
Login To Rate This Project

User Ratings

★★★★★
★★★★
★★★
★★
1
0
0
0
0
ease 1 of 5 2 of 5 3 of 5 4 of 5 5 of 5 5 / 5
features 1 of 5 2 of 5 3 of 5 4 of 5 5 of 5 5 / 5
design 1 of 5 2 of 5 3 of 5 4 of 5 5 of 5 5 / 5
support 1 of 5 2 of 5 3 of 5 4 of 5 5 of 5 5 / 5

User Reviews

  • i like it
Read more reviews >

Additional Project Details

Registered

2022-02-13