Database Schema
Sql
-- Students table
CREATE TABLE students (
id INT AUTO_INCREMENT PRIMARY KEY,
reg_number VARCHAR(20) UNIQUE,
surname VARCHAR(50),
first_name VARCHAR(50),
other_name VARCHAR(50),
sex ENUM('Male', 'Female'),
state VARCHAR(50),
nationality VARCHAR(50),
dob DATE,
age INT,
student_phone VARCHAR(15),
home_address TEXT,
health_conditions TEXT,
father_name VARCHAR(100),
father_phone VARCHAR(15),
father_occupation VARCHAR(100),
mother_name VARCHAR(100),
mother_phone VARCHAR(15),
mother_occupation VARCHAR(100),
sponsor_name VARCHAR(100),
sponsor_phone VARCHAR(15),
sponsor_relationship VARCHAR(50),
class_id INT,
password VARCHAR(100),
registration_date DATE,
FOREIGN KEY (class_id) REFERENCES classes(id)
);
-- Classes table
CREATE TABLE classes (
id INT AUTO_INCREMENT PRIMARY KEY,
class_name VARCHAR(20),
class_teacher_id INT
);
-- Subjects table
CREATE TABLE subjects (
id INT AUTO_INCREMENT PRIMARY KEY,
subject_name VARCHAR(50),
subject_code VARCHAR(10)
);
-- Results table
CREATE TABLE results (
id INT AUTO_INCREMENT PRIMARY KEY,
student_id INT,
subject_id INT,
term ENUM('First Term', 'Second Term', 'Third Term'),
session VARCHAR(20),
cat_score INT,
assignment_score INT,
exam_score INT,
total_score INT,
grade CHAR(1),
FOREIGN KEY (student_id) REFERENCES students(id),
FOREIGN KEY (subject_id) REFERENCES subjects(id)
);
-- Fees table
CREATE TABLE fees (
id INT AUTO_INCREMENT PRIMARY KEY,
student_id INT,
term ENUM('First Term', 'Second Term', 'Third Term'),
session VARCHAR(20),
amount DECIMAL(10,2),
amount_paid DECIMAL(10,2),
payment_date DATE,
teller_number VARCHAR(20),
FOREIGN KEY (student_id) REFERENCES students(id)
);
-- Attendance table
CREATE TABLE attendance (
id INT AUTO_INCREMENT PRIMARY KEY,
student_id INT,
date DATE,
status ENUM('Present', 'Absent'),
term ENUM('First Term', 'Second Term', 'Third Term'),
session VARCHAR(20),
FOREIGN KEY (student_id) REFERENCES students(id)
);
-- Staff table
CREATE TABLE staff (
id INT AUTO_INCREMENT PRIMARY KEY,
staff_name VARCHAR(100),
role VARCHAR(50),
salary DECIMAL(10,2),
phone VARCHAR(15),
email VARCHAR(100),
password VARCHAR(100)
);
-- Payroll table
CREATE TABLE payroll (
id INT AUTO_INCREMENT PRIMARY KEY,
staff_id INT,
amount DECIMAL(10,2),
payment_date DATE,
FOREIGN KEY (staff_id) REFERENCES staff(id)
);
-- Pins table (for result checking)
CREATE TABLE pins (
id INT AUTO_INCREMENT PRIMARY KEY,
pin_number VARCHAR(20) UNIQUE,
serial_number VARCHAR(20),
term ENUM('First Term', 'Second Term', 'Third Term'),
session VARCHAR(20),
is_used BOOLEAN DEFAULT FALSE,
used_by INT,
used_date DATETIME,
FOREIGN KEY (used_by) REFERENCES students(id)
);
Login System (PHP)
<?php
// [Link]
session_start();
require_once 'db_config.php';
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$username = $_POST['username'];
$password = $_POST['password'];
// Check in staff table
$stmt = $conn->prepare("SELECT * FROM staff WHERE email = ?");
$stmt->bind_param("s", $username);
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows > 0) {
$user = $result->fetch_assoc();
if (password_verify($password, $user['password'])) {
$_SESSION['user_id'] = $user['id'];
$_SESSION['user_name'] = $user['staff_name'];
$_SESSION['user_role'] = $user['role'];
// Redirect based on role
switch($user['role']) {
case 'Admin':
header("Location: admin_dashboard.php");
break;
case 'Accountant':
header("Location: accountant_dashboard.php");
break;
case 'Teacher':
header("Location: teacher_dashboard.php");
break;
default:
header("Location: [Link]");
exit();
// If not found in staff, check students
$stmt = $conn->prepare("SELECT * FROM students WHERE reg_number = ?");
$stmt->bind_param("s", $username);
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows > 0) {
$student = $result->fetch_assoc();
if ($password == $student['password']) { // Note: In production, use password hashing
$_SESSION['student_id'] = $student['id'];
$_SESSION['student_name'] = $student['first_name'] . ' ' . $student['surname'];
$_SESSION['student_class'] = $student['class_id'];
header("Location: student_portal.php");
exit();
// If neither, show error
$_SESSION['error'] = "Invalid username or password";
header("Location: [Link]");
exit();
?>
Admin Dashboard (admin_dashboard.php)
<?php
// admin_dashboard.php
require_once 'auth_check.php'; // Checks if user is logged in and is admin
// Get current date
$currentDate = date('d M-Y H:i:s');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>NKST SEC SCH - Admin Dashboard</title>
<link rel="stylesheet" href="css/[Link]">
<link rel="stylesheet" href="css/[Link]">
<link rel="stylesheet" href="css/[Link]">
</head>
<body>
<div class="container-fluid">
<div class="row">
<!-- Sidebar -->
<div class="col-md-3 sidebar">
<h2 class="text-center">NKST SEC SCH</h2>
<p class="text-center"><?php echo $currentDate; ?></p>
<div class="profile-section text-center">
<img src="images/[Link]" alt="Profile" class="profile-img">
<h4><?php echo $_SESSION['user_name']; ?></h4>
<p>Administrator</p>
</div>
<ul class="nav flex-column">
<li class="nav-item active">
<a class="nav-link" href="admin_dashboard.php">
<i class="fa fa-dashboard"></i> Dashboard
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="portal_requests.php">
<i class="fa fa-envelope"></i> Portal Request
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="[Link]">
<i class="fa fa-user"></i> Profile
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="administrative_manager.php">
<i class="fa fa-cogs"></i> Administrative Manager
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="student_management.php">
<i class="fa fa-users"></i> Student Management
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="class_attendance.php">
<i class="fa fa-check-square"></i> Class Attendance
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="view_attendance.php">
<i class="fa fa-list"></i> View Attendance Records
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="behavioral_analysis.php">
<i class="fa fa-bar-chart"></i> Behavioral Analysis
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="class_management.php">
<i class="fa fa-building"></i> Class Management
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="subject_management.php">
<i class="fa fa-book"></i> Subject Management
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="result_management.php">
<i class="fa fa-graduation-cap"></i> Result Management
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="[Link]">
<i class="fa fa-sign-out"></i> Logout
</a>
</li>
</ul>
</div>
<!-- Main Content -->
<div class="col-md-9 main-content">
<div class="header">
<h3>Admin Dashboard</h3>
<p>Welcome back, <?php echo $_SESSION['user_name']; ?></p>
</div>
<div class="dashboard-cards row">
<div class="col-md-4">
<div class="card">
<div class="card-body">
<h5 class="card-title">Total Students</h5>
<p class="card-text"><?php echo getTotalStudents(); ?></p>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card">
<div class="card-body">
<h5 class="card-title">Total Staff</h5>
<p class="card-text"><?php echo getTotalStaff(); ?></p>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card">
<div class="card-body">
<h5 class="card-title">Fee Collection</h5>
<p class="card-text">₦<?php echo number_format(getTotalFees(), 2); ?></p>
</div>
</div>
</div>
</div>
<div class="recent-activities mt-4">
<h4>Recent Activities</h4>
<ul class="list-group">
<?php foreach(getRecentActivities() as $activity): ?>
<li class="list-group-item"><?php echo $activity; ?></li>
<?php endforeach; ?>
</ul>
</div>
</div>
</div>
</div>
<footer class="footer">
<p class="text-center">Copyright © <?php echo date('Y'); ?> | Product of nghb | jh</p>
</footer>
<script src="js/[Link]"></script>
<script src="js/[Link]"></script>
<script src="js/[Link]"></script>
</body>
</html>
Student Management (student_management.php)
<?php
// student_management.php
require_once 'auth_check.php';
// Handle form submissions
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (isset($_POST['add_student'])) {
// Add new student logic
} elseif (isset($_POST['edit_student'])) {
// Edit student logic
} elseif (isset($_POST['delete_student'])) {
// Delete student logic
// Get all students
$students = getAllStudents();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Student Management</title>
<!-- Include CSS and JS files -->
</head>
<body>
<!-- Include sidebar from dashboard -->
<div class="col-md-9 main-content">
<div class="header">
<h3>Student Management</h3>
</div>
<div class="card mb-4">
<div class="card-header">
<h5>Add New Student</h5>
</div>
<div class="card-body">
<form method="POST">
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label>Surname</label>
<input type="text" name="surname" class="form-control" required>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label>First Name</label>
<input type="text" name="first_name" class="form-control" required>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label>Other Name</label>
<input type="text" name="other_name" class="form-control">
</div>
</div>
</div>
<!-- More student fields -->
<button type="submit" name="add_student" class="btn btn-primary">Add Student</button>
</form>
</div>
</div>
<div class="card">
<div class="card-header">
<h5>View Students</h5>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-striped" id="studentsTable">
<thead>
<tr>
<th>S/N</th>
<th>Passport</th>
<th>Student Name</th>
<th>Sex</th>
<th>Class</th>
<th>Phone</th>
<th>Reg Number</th>
<th>Password</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php foreach($students as $index => $student): ?>
<tr>
<td><?php echo $index + 1; ?></td>
<td>No</td>
<td><?php echo $student['surname'] . ' ' . $student['first_name'] . ' ' .
$student['other_name']; ?></td>
<td><?php echo $student['sex']; ?></td>
<td><?php echo getClassName($student['class_id']); ?></td>
<td><?php echo $student['student_phone']; ?></td>
<td><?php echo $student['reg_number']; ?></td>
<td><?php echo $student['password']; ?></td>
<td>
<a href="edit_student.php?id=<?php echo $student['id']; ?>" class="btn btn-sm btn-
info">Edit</a>
<a href="delete_student.php?id=<?php echo $student['id']; ?>" class="btn btn-sm btn-
danger" onclick="return confirm('Are you sure?')">Delete</a>
<a href="print_slip.php?id=<?php echo $student['id']; ?>" class="btn btn-sm btn-
success">Slip</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- Include footer -->
</body>
</html>
Result Management (result_management.php)
<?php
// result_management.php
require_once 'auth_check.php';
// Handle form submissions
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (isset($_POST['publish_result'])) {
// Publish result logic
} elseif (isset($_POST['delete_result'])) {
// Delete result logic
// Get published results
$results = getPublishedResults();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Result Management</title>
<!-- Include CSS and JS files -->
</head>
<body>
<!-- Include sidebar from dashboard -->
<div class="col-md-9 main-content">
<div class="header">
<h3>Result Management</h3>
</div>
<div class="card mb-4">
<div class="card-header">
<h5>View Published Results</h5>
</div>
<div class="card-body">
<form method="GET" class="form-inline mb-3">
<div class="form-group mr-2">
<label class="mr-2">Student Class:</label>
<select name="class" class="form-control">
<option value="">--select--</option>
<?php foreach(getAllClasses() as $class): ?>
<option value="<?php echo $class['id']; ?>"><?php echo $class['class_name']; ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="form-group mr-2">
<label class="mr-2">Term:</label>
<select name="term" class="form-control">
<option value="">--select--</option>
<option value="First Term">First Term</option>
<option value="Second Term">Second Term</option>
<option value="Third Term">Third Term</option>
</select>
</div>
<div class="form-group mr-2">
<label class="mr-2">Session:</label>
<input type="text" name="session" class="form-control" value="2018/2019">
</div>
<button type="submit" name="view_published" class="btn btn-primary">VIEW
PUBLISHED</button>
<button type="submit" name="delete" class="btn btn-danger ml-2">DELETE</button>
</form>
<div class="table-responsive">
<table class="table table-striped" id="resultsTable">
<thead>
<tr>
<th>S/N</th>
<th>NAME</th>
<th>REG NO.</th>
<th>CLASS</th>
<th>TERM</th>
<th>SESSION</th>
<th>TOTAL</th>
<th>AVERAGE</th>
<th>POSITION</th>
<th>Final Comment</th>
<th>ACTION</th>
</tr>
</thead>
<tbody>
<?php foreach($results as $index => $result): ?>
<tr>
<td><?php echo $index + 1; ?></td>
<td><?php echo $result['student_name']; ?></td>
<td><?php echo $result['reg_number']; ?></td>
<td><?php echo $result['class_name']; ?></td>
<td><?php echo $result['term']; ?></td>
<td><?php echo $result['session']; ?></td>
<td><?php echo $result['total_score']; ?></td>
<td><?php echo number_format($result['average'], 3); ?></td>
<td><?php echo $result['position']; ?></td>
<td>REPORT SHEET COMMENT</td>
<td>
<a href="report_sheet.php?id=<?php echo $result['student_id']; ?>&term=<?php echo
$result['term']; ?>&session=<?php echo $result['session']; ?>" class="btn btn-sm btn-primary">Report
Sheet</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- Include footer -->
</body>
</html>
Report sheet generation (report_sheet.php)
<?php
// report_sheet.php
require_once 'auth_check.php';
$student_id = $_GET['id'];
$term = $_GET['term'];
$session = $_GET['session'];
// Get student details
$student = getStudentById($student_id);
// Get student results
$results = getStudentResults($student_id, $term, $session);
// Get performance summary
$summary = getPerformanceSummary($student_id, $term, $session);
// Generate PDF report
require_once 'tcpdf/[Link]';
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('NKST Secondary School');
$pdf->SetTitle('Report Sheet - ' . $student['first_name'] . ' ' . $student['surname']);
$pdf->SetSubject('Terminal Report');
$pdf->SetKeywords('Report, School, NKST');
$pdf->setHeaderData('', 0, 'NKST SECONDARY SCHOOL', 'KORINYA CITY, BENUE STATE');
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
$pdf->AddPage();
// School logo and title
$html = '<h1 style="text-align:center;">NKST SECONDARY SCHOOL</h1>';
$html .= '<h2 style="text-align:center;">KORINYA CITY, BENUE STATE</h2>';
$html .= '<h3 style="text-align:center;">' . $term . ' Report Sheet for ' . $session . ' Session</h3>';
// Student information
$html .= '<p><strong>NAME:</strong> ' . strtoupper($student['surname'] . ' ' .
strtoupper($student['first_name'] . ' ' . strtoupper($student['other_name']) . '</p>';
$html .= '<p><strong>REG NO:</strong> ' . $student['reg_number'] . '</p>';
$html .= '<p><strong>CLASS:</strong> ' . getClassName($student['class_id']) . '</p>';
$html .= '<p><strong>SEX:</strong> ' . $student['sex'] . '</p>';
// Results table
$html .= '<table border="1" cellpadding="5">
<thead>
<tr>
<th>SUBJECTS</th>
<th>CAT (15)</th>
<th>ASSIGN (25)</th>
<th>EXAM (60)</th>
<th>TOTAL (100)</th>
<th>GRADE</th>
</tr>
</thead>
<tbody>';
foreach ($results as $result) {
$html .= '<tr>
<td>' . $result['subject_name'] . '</td>
<td>' . $result['cat_score'] . '</td>
<td>' . $result['assignment_score'] . '</td>
<td>' . $result['exam_score'] . '</td>
<td>' . $result['total_score'] . '</td>
<td>' . $result['grade'] . '</td>
</tr>';
$html .= '</tbody></table>';
// Performance summary
$html .= '<h4>PERFORMANCE REPORT</h4>';
$html .= '<p>MARKS OBTAINABLE: ' . $summary['total_obtainable'] . ' MARKS OBTAINED: ' .
$summary['total_obtained'] .
' AVERAGE: ' . $summary['average'] . ' NUMBER IN CLASS: ' . $summary['class_size'] .
' POSITION: ' . $summary['position'] . '</p>';
$html .= '<p>REMARKS/COMMENTS: ' . $summary['comment'] . '</p>';
$pdf->writeHTML($html, true, false, true, false, '');
$pdf->Output('report_sheet_' . $student['reg_number'] . '.pdf', 'I');
?>
Fee management (fee_management.php)
<?php
// fee_management.php
Require_once ‘auth_check.php’;
// Handle form submissions
If ($_SERVER[‘REQUEST_METHOD’] == ‘POST’) {
If (isset($_POST[‘allocate_fee’])) {
// Allocate fee logic
} elseif (isset($_POST[‘record_payment’])) {
// Record payment logic
// Get fee records
$fee_records = getFeeRecords();
?>
<!DOCTYPE html>
<html lang=”en”>
<head>
<meta charset=”UTF-8”>
<title>Fee Management</title>
<!—Include CSS and JS files
</head>
<body>
<!—Include sidebar from dashboard
<div class=”col-md-9 main-content”>
<div class=”header”>
<h3>Fee Management</h3>
</div>
<div class=”card mb-4”>
<div class=”card-header”>
<h5>Record Students Fees</h5>
</div>
<div class=”card-body”>
<form method=”POST”>
<div class=”row”>
<div class=”col-md-4”>
<div class=”form-group”>
<label>Student Reg No</label>
<input type=”text” name=”reg_number” class=”form-control” placeholder=”Enter
Student Reg Numb”>
</div>
</div>
<div class=”col-md-4”>
<div class=”form-group”>
<label>Student Class</label>
<select name=”class” class=”form-control”>
<option value=””>--select--</option>
<?php foreach(getAllClasses() as $class): ?>
<option value=”<?php echo $class[‘id’]; ?>”><?php echo $class[‘class_name’];
?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class=”col-md-4”>
<div class=”form-group”>
<label>Student Type</label>
<select name=”student_type” class=”form-control”>
<option value=””>--select--</option>
<option value=”Regular”>Regular</option>
<option value=”Boarder”>Boarder</option>
</select>
</div>
</div>
</div>
<div class=”row mt-3”>
<div class=”col-md-3”>
<div class=”form-group”>
<label>Fee Term</label>
<select name=”term” class=”form-control”>
<option value=””>--select--</option>
<option value=”First Term”>First Term</option>
<option value=”Second Term”>Second Term</option>
<option value=”Third Term”>Third Term</option>
</select>
</div>
</div>
<div class=”col-md-3”>
<div class=”form-group”>
<label>Fee Session</label>
<select name=”session” class=”form-control”>
<option value=””>--select--</option>
<option value=”2018/2019”>2018/2019</option>
<option value=”2019/2020”>2019/2020</option>
</select>
</div>
</div>
<div class=”col-md-3”>
<div class=”form-group”>
<label>Amount Paid</label>
<input type=”number” name=”amount” class=”form-control” placeholder=”Enter Fees
Arr”>
</div>
</div>
<div class=”col-md-3”>
<div class=”form-group”>
<label>Teller No</label>
<input type=”text” name=”teller_no” class=”form-control” placeholder=”Enter Bank
Teller”>
</div>
</div>
</div>
<button type=”submit” name=”record_payment” class=”btn btn-primary”>SAVE FEE
PAYMENT</button>
</form>
</div>
</div>
<div class=”card”>
<div class=”card-header”>
<h5>View Fee Records</h5>
</div>
<div class=”card-body”>
<form method=”GET” class=”form-inline mb-3”>
<div class=”form-group mr-2”>
<label class=”mr-2”>Class:</label>
<select name=”class” class=”form-control”>
<option value=””>--select--</option>
<?php foreach(getAllClasses() as $class): ?>
<option value=”<?php echo $class[‘id’]; ?>”><?php echo $class[‘class_name’]; ?></option>
<?php endforeach; ?>
</select>
</div>
<div class=”form-group mr-2”>
<label class=”mr-2”>Term:</label>
<select name=”term” class=”form-control”>
<option value=””>--select--</option>
<option value=”First Term”>First Term</option>
<option value=”Second Term”>Second Term</option>
<option value=”Third Term”>Third Term</option>
</select>
</div>
<div class=”form-group mr-2”>
<label class=”mr-2”>Session:</label>
<select name=”session” class=”form-control”>
<option value=””>--select--</option>
<option value=”2018/2019”>2018/2019</option>
<option value=”2019/2020”>2019/2020</option>
</select>
</div>
<button type=”submit” name=”view_records” class=”btn btn-primary”>VIEW</button>
</form>
<div class=”table-responsive”>
<table class=”table table-striped” id=”feeTable”>
<thead>
<tr>
<th>S/N</th>
<th>Student Name</th>
<th>Reg Number</th>
<th>Class</th>
<th>Term</th>
<th>Session</th>
<th>Amount Paid</th>
<th>Date Paid</th>
<th>Teller No</th>
</tr>
</thead>
<tbody>
<?php foreach($fee_records as $index => $record): ?>
<tr>
<td><?php echo $index + 1; ?></td>
<td><?php echo $record[‘student_name’]; ?></td>
<td><?php echo $record[‘reg_number’]; ?></td>
<td><?php echo $record[‘class_name’]; ?></td>
<td><?php echo $record[‘term’]; ?></td>
<td><?php echo $record[‘session’]; ?></td>
<td>₦<?php echo number_format($record[‘amount_paid’], 2); ?></td>
<td><?php echo date(‘d-M-Y’, strtotime($record[‘payment_date’])); ?></td>
<td><?php echo $record[‘teller_number’]; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<!—Include footer
</body>
</html>
Pin Management (pin_management.php)
<?php
// pin_management.php
require_once 'auth_check.php';
// Handle form submissions
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (isset($_POST['generate_pin'])) {
// Generate PIN logic
$quantity = $_POST['quantity'];
$term = $_POST['term'];
$session = $_POST['session'];
$generated_pins = [];
for ($i = 0; $i < $quantity; $i++) {
$pin = generateRandomPin();
$serial = generateSerialNumber();
// Save to database
savePin($pin, $serial, $term, $session);
$generated_pins[] = [
'pin' => $pin,
'serial' => $serial
];
} elseif (isset($_POST['upload_pin'])) {
// Upload PIN logic
// Get generated pins
$pins = getGeneratedPins();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>PIN Management</title>
<!-- Include CSS and JS files -->
</head>
<body>
<!-- Include sidebar from dashboard -->
<div class="col-md-9 main-content">
<div class="header">
<h3>Generate PIN</h3>
</div>
<div class="card mb-4">
<div class="card-header">
<h5>GENERATE PIN</h5>
</div>
<div class="card-body">
<form method="POST">
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label>Number of Pins</label>
<input type="number" name="quantity" class="form-control" min="1" max="100"
value="5">
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label>Term</label>
<select name="term" class="form-control">
<option value="">--select--</option>
<option value="First Term">First Term</option>
<option value="Second Term">Second Term</option>
<option value="Third Term">Third Term</option>
</select>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label>Session</label>
<select name="session" class="form-control">
<option value="">--select--</option>
<option value="2018/2019">2018/2019</option>
<option value="2019/2020">2019/2020</option>
</select>
</div>
</div>
</div>
<button type="submit" name="generate_pin" class="btn btn-primary">GENERATE
PINS</button>
</form>
<?php if (isset($generated_pins) && !empty($generated_pins)): ?>
<div class="mt-4">
<h5>Generated Pins:</h5>
<table class="table table-bordered">
<thead>
<tr>
<th>GEN PIN</th>
<th>SERIAL NUMBER</th>
</tr>
</thead>
<tbody>
<?php foreach($generated_pins as $pin): ?>
<tr>
<td><?php echo $pin['pin']; ?></td>
<td><?php echo $pin['serial']; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php endif; ?>
</div>
</div>
<div class="card mb-4">
<div class="card-header">
<h5>UPLOAD PIN</h5>
</div>
<div class="card-body">
<form method="POST" enctype="multipart/form-data">
<div class="form-group">
<label>Upload PIN File</label>
<input type="file" name="pin_file" class="form-control-file">
</div>
<button type="submit" name="upload_pin" class="btn btn-primary">UPLOAD</button>
</form>
</div>
</div>
<div class="card">
<div class="card-header">
<h5>View Uploaded Pins</h5>
</div>
<div class="card-body">
<form method="GET" class="form-inline mb-3">
<div class="form-group mr-2">
<label class="mr-2">Term:</label>
<select name="term" class="form-control">
<option value="">--select--</option>
<option value="First Term">First Term</option>
<option value="Second Term">Second Term</option>
<option value="Third Term">Third Term</option>
</select>
</div>
<button type="submit" name="view_pins" class="btn btn-primary">VIEW UPLOADED
PIN</button>
<button type="button" class="btn btn-secondary ml-2">LEAVE THIS PAGE</button>
</form>
<div class="table-responsive">
<table class="table table-striped" id="pinsTable">
<thead>
<tr>
<th>PIN</th>
<th>SERIAL NUMBER</th>
<th>TERM</th>
<th>SESSION</th>
<th>STATUS</th>
<th>ACTION</th>
</tr>
</thead>
<tbody>
<?php foreach($pins as $pin): ?>
<tr>
<td><?php echo $pin['pin_number']; ?></td>
<td><?php echo $pin['serial_number']; ?></td>
<td><?php echo $pin['term']; ?></td>
<td><?php echo $pin['session']; ?></td>
<td><?php echo $pin['is_used'] ? 'Used' : 'Unused'; ?></td>
<td>
<button class="btn btn-sm btn-danger" onclick="deletePin(<?php echo $pin['id']; ?
>)">DELETE</button>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- Include footer -->
<script>
function deletePin(pinId) {
if (confirm('Are you sure you want to delete this PIN?')) {
[Link] = 'delete_pin.php?id=' + pinId;
</script>
</body>
</html>
Staff payroll (staff_payroll.php)
<?php
// staff_payroll.php
require_once 'auth_check.php';
// Handle form submissions
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (isset($_POST['add_staff'])) {
// Add staff to payroll logic
} elseif (isset($_POST['record_payment'])) {
// Record payment logic
// Get staff payroll records
$payroll_records = getPayrollRecords();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Staff Payroll</title>
<!-- Include CSS and JS files -->
</head>
<body>
<!-- Include sidebar from dashboard -->
<div class="col-md-9 main-content">
<div class="header">
<h3>Staff Payroll</h3>
</div>
<div class="card mb-4">
<div class="card-header">
<h5>Add New Staff to Payroll</h5>
</div>
<div class="card-body">
<form method="POST">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>Staff Name</label>
<input type="text" name="staff_name" class="form-control" placeholder="Enter Staff
Name">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Salary (₦)</label>
<input type="number" name="salary" class="form-control" placeholder="Enter Staff
Salary">
</div>
</div>
</div>
<button type="submit" name="add_staff" class="btn btn-primary">SAVE</button>
</form>
</div>
</div>
<div class="card">
<div class="card-header">
<h5>View Staff Payroll</h5>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-striped" id="payrollTable">
<thead>
<tr>
<th>S/N</th>
<th>STAFF NAME</th>
<th>SALARY (₦)</th>
<th>DATE</th>
<th>ACTION</th>
</tr>
</thead>
<tbody>
<?php foreach($payroll_records as $index => $record): ?>
<tr>
<td><?php echo $index + 1; ?></td>
<td><?php echo $record['staff_name']; ?></td>
<td><?php echo number_format($record['salary'], 2); ?></td>
<td><?php echo date('d-M-Y', strtotime($record['payment_date'])); ?></td>
<td>
<button class="btn btn-sm btn-danger" onclick="deleteRecord(<?php echo
$record['id']; ?>)">DELETE</button>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<div class="mt-3">
<h5>Total Staff Salaries Per Month: ₦<?php echo number_format(calculateTotalSalaries(), 2); ?
></h5>
</div>
</div>
</div>
</div>
<!-- Include footer -->
<script>
function deleteRecord(id) {
if (confirm('Are you sure you want to delete this record?')) {
[Link] = 'delete_payroll.php?id=' + id;
</script>
</body>
</html>
CSS Styling ([Link])
/* General Styles */
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #f5f5f5;
color: #333;
}
.container-fluid {
padding: 0;
/* Sidebar Styles */
.sidebar {
background-color: #2c3e50;
color: white;
min-height: 100vh;
padding: 20px 0;
.sidebar h2 {
margin-bottom: 30px;
font-size: 24px;
.profile-section {
margin-bottom: 30px;
padding: 0 15px;
.profile-img {
width: 100px;
height: 100px;
border-radius: 50%;
margin-bottom: 10px;
border: 3px solid #3498db;
}
.nav {
margin-top: 20px;
.nav-item {
margin-bottom: 5px;
.nav-link {
color: #ecf0f1;
padding: 10px 15px;
border-radius: 0;
transition: all 0.3s;
.nav-link:hover {
background-color: #34495e;
color: white;
.nav-link i {
margin-right: 10px;
.[Link] .nav-link {
background-color: #3498db;
color: white;
}
/* Main Content Styles */
.main-content {
padding: 20px;
.header {
margin-bottom: 30px;
padding-bottom: 15px;
border-bottom: 1px solid #ddd;
.header h3 {
font-weight: 600;
color: #2c3e50;
/* Card Styles */
.card {
margin-bottom: 30px;
border: none;
border-radius: 5px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
.card-header {
background-color: #3498db;
color: white;
border-radius: 5px 5px 0 0 !important;
padding: 15px 20px;
border: none;
}
.card-header h5 {
margin: 0;
font-weight: 600;
.card-body {
padding: 20px;
/* Table Styles */
.table {
width: 100%;
margin-bottom: 1rem;
color: #212529;
border-collapse: collapse;
.table th {
background-color: #f8f9fa;
border-bottom: 2px solid #dee2e6;
padding: 12px;
text-align: left;
.table td {
padding: 12px;
border-top: 1px solid #dee2e6;
vertical-align: middle;
}
.table-striped tbody tr:nth-of-type(odd) {
background-color: rgba(0, 0, 0, 0.02);
/* Form Styles */
.form-control {
height: 40px;
border-radius: 3px;
border: 1px solid #ddd;
.form-group {
margin-bottom: 15px;
.btn {
padding: 8px 20px;
border-radius: 3px;
font-weight: 500;
transition: all 0.3s;
.btn-primary {
background-color: #3498db;
border-color: #3498db;
.btn-primary:hover {
background-color: #2980b9;
border-color: #2980b9;
.btn-danger {
background-color: #e74c3c;
border-color: #e74c3c;
.btn-danger:hover {
background-color: #c0392b;
border-color: #c0392b;
/* Footer Styles */
.footer {
background-color: #2c3e50;
color: white;
padding: 15px 0;
text-align: center;
margin-top: 30px;
/* Responsive Styles */
@media (max-width: 768px) {
.sidebar {
min-height: auto;
position: relative;
}
.main-content {
padding: 15px;
JavaScript Functions ([Link])
$(document).ready(function() {
// Initialize DataTables
$('#studentsTable').DataTable();
$('#resultsTable').DataTable();
$('#feeTable').DataTable();
$('#pinsTable').DataTable();
$('#payrollTable').DataTable();
// Date picker for attendance
$('.datepicker').datepicker({
format: 'dd/mm/yyyy',
autoclose: true
});
// Form validation
$('form').on('submit', function() {
let isValid = true;
$(this).find('[required]').each(function() {
if ($(this).val() === '') {
$(this).addClass('is-invalid');
isValid = false;
} else {
$(this).removeClass('is-invalid');
}
});
return isValid;
});
// Auto-generate registration number
$('#generateRegNo').click(function() {
const currentYear = new Date().getFullYear();
const randomNum = [Link](1000 + [Link]() * 9000);
const regNo = currentYear + 'FSTCMICH' + randomNum;
$('#reg_number').val(regNo);
});
});
// Generate random PIN for result checking
function generateRandomPin() {
let pin = '';
for (let i = 0; i < 16; i++) {
pin += [Link]([Link]() * 10);
return pin;
// Print report sheet
function printReportSheet() {
[Link]();
// Confirm before deleting records
function confirmDelete() {
return confirm('Are you sure you want to delete this record?');
}
Helper Functions ([Link])
<?php
// Database connection
function getDBConnection() {
$host = 'localhost';
$username = 'root';
$password = '';
$dbname = 'nkst_school';
try {
$conn = new PDO("mysql:host=$host;dbname=$dbname", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
return $conn;
} catch(PDOException $e) {
die("Connection failed: " . $e->getMessage());
// Get all students
function getAllStudents() {
$conn = getDBConnection();
$stmt = $conn->prepare("SELECT * FROM students");
$stmt->execute();
return $stmt->fetchAll(PDO::FETCH_ASSOC);
// Get student by ID
function getStudentById($id) {
$conn = getDBConnection();
$stmt = $conn->prepare("SELECT * FROM students WHERE id = ?");
$stmt->execute([$id]);
return $stmt->fetch(PDO::FETCH_ASSOC);
// Get class name by ID
function getClassName($id) {
$conn = getDBConnection();
$stmt = $conn->prepare("SELECT class_name FROM classes WHERE id = ?");
$stmt->execute([$id]);
$result = $stmt->fetch(PDO::FETCH_ASSOC);
return $result ? $result['class_name'] : '';
// Get all classes
function getAllClasses() {
$conn = getDBConnection();
$stmt = $conn->prepare("SELECT * FROM classes");
$stmt->execute();
return $stmt->fetchAll(PDO::FETCH_ASSOC);
// Get published results
function getPublishedResults($class_id = null, $term = null, $session = null) {
$conn = getDBConnection();
$sql = "SELECT [Link] as student_id, CONCAT([Link], ' ', s.first_name, ' ', s.other_name) as
student_name,
s.reg_number, c.class_name, [Link], [Link],
SUM(r.total_score) as total_score, AVG(r.total_score) as average,
(SELECT COUNT(*) FROM results WHERE term = [Link] AND session = [Link] AND student_id IN
(SELECT id FROM students WHERE class_id = s.class_id)) as class_size,
(SELECT COUNT(*) FROM results WHERE term = [Link] AND session = [Link] AND student_id IN
(SELECT id FROM students WHERE class_id = s.class_id) AND SUM(total_score) >
(SELECT SUM(total_score) FROM results WHERE student_id = [Link] AND term = [Link] AND
session = [Link])) + 1 as position
FROM results r
JOIN students s ON r.student_id = [Link]
JOIN classes c ON s.class_id = [Link]
WHERE 1=1";
$params = [];
if ($class_id) {
$sql .= " AND s.class_id = ?";
$params[] = $class_id;
if ($term) {
$sql .= " AND [Link] = ?";
$params[] = $term;
if ($session) {
$sql .= " AND [Link] = ?";
$params[] = $session;
$sql .= " GROUP BY [Link], [Link], [Link]";
$stmt = $conn->prepare($sql);
$stmt->execute($params);
return $stmt->fetchAll(PDO::FETCH_ASSOC);
// Get student results
function getStudentResults($student_id, $term, $session) {
$conn = getDBConnection();
$stmt = $conn->prepare("SELECT s.subject_name, r.cat_score, r.assignment_score, r.exam_score,
r.total_score, [Link]
FROM results r
JOIN subjects s ON r.subject_id = [Link]
WHERE r.student_id = ? AND [Link] = ? AND [Link] = ?");
$stmt->execute([$student_id, $term, $session]);
return $stmt->fetchAll(PDO::FETCH_ASSOC);
// Get performance summary
function getPerformanceSummary($student_id, $term, $session) {
$conn = getDBConnection();
// Get student's total score
$stmt = $conn->prepare("SELECT SUM(total_score) as total_obtained FROM results
WHERE student_id = ? AND term = ? AND session = ?");
$stmt->execute([$student_id, $term, $session]);
$total_obtained = $stmt->fetch(PDO::FETCH_ASSOC)['total_obtained'];
// Get total obtainable (assuming 14 subjects * 100)
$total_obtainable = 1400;
// Calculate average
$average = $total_obtained / 14;
// Get class size
$stmt = $conn->prepare("SELECT COUNT(*) as class_size FROM students
WHERE class_id = (SELECT class_id FROM students WHERE id = ?)");
$stmt->execute([$student_id]);
$class_size = $stmt->fetch(PDO::FETCH_ASSOC)['class_size'];
// Get position
$stmt = $conn->prepare("SELECT COUNT(*) + 1 as position FROM students s
JOIN results r ON [Link] = r.student_id
WHERE s.class_id = (SELECT class_id FROM students WHERE id = ?)
AND [Link] = ? AND [Link] = ?
GROUP BY [Link]
HAVING SUM(r.total_score) > ?");
$stmt->execute([$student_id, $term, $session, $total_obtained]);
$position = $stmt->rowCount() + 1;
// Determine comment based on average
if ($average >= 75) {
$comment = "Excellent performance. Keep it up!";
} elseif ($average >= 60) {
$comment = "Good performance. You can do better.";
} elseif ($average >= 50) {
$comment = "Fair performance. More effort is needed.";
} else {
$comment = "Poor performance. You need to work harder.";
}
return [
'total_obtainable' => $total_obtainable,
'total_obtained' => $total_obtained,
'average' => number_format($average, 3),
'class_size' => $class_size,
'position' => $position,
'comment' => $comment
];
// Generate random PIN
function generateRandomPin() {
return str_pad(mt_rand(0, 9999999999999999), 16, '0', STR_PAD_LEFT);
// Generate serial number
function generateSerialNumber() {
return date('Ymd') . str_pad(mt_rand(0, 999), 3, '0', STR_PAD_LEFT);
// Save PIN to database
function savePin($pin, $serial, $term, $session) {
$conn = getDBConnection();
$stmt = $conn->prepare("INSERT INTO pins (pin_number, serial_number, term, session) VALUES (?, ?, ?,
?)");
return $stmt->execute([$pin, $serial, $term, $session]);
// Get generated pins
function getGeneratedPins($term = null, $session = null) {
$conn = getDBConnection();
$sql = "SELECT * FROM pins WHERE 1=1";
$params = [];
if ($term) {
$sql .= " AND term = ?";
$params[] = $term;
if ($session) {
$sql .= " AND session = ?";
$params[] = $session;
$stmt = $conn->prepare($sql);
$stmt->execute($params);
return $stmt->fetchAll(PDO::FETCH_ASSOC);
// Get fee records
function getFeeRecords($class_id = null, $term = null, $session = null) {
$conn = getDBConnection();
$sql = "SELECT f.*, CONCAT([Link], ' ', s.first_name, ' ', s.other_name) as student_name,
s.reg_number, c.class_name
FROM fees f
JOIN students s ON f.student_id = [Link]
JOIN classes c ON s.class_id = [Link]
WHERE 1=1";
$params = [];
if ($class_id) {
$sql .= " AND s.class_id = ?";
$params[] = $class_id;
if ($term) {
$sql .= " AND [Link] = ?";
$params[] = $term;
if ($session) {
$sql .= " AND [Link] = ?";
$params[] = $session;
$sql .= " ORDER BY f.payment_date DESC";
$stmt = $conn->prepare($sql);
$stmt->execute($params);
return $stmt->fetchAll(PDO::FETCH_ASSOC);
// Get payroll records
function getPayrollRecords() {
$conn = getDBConnection();
$stmt = $conn->prepare("SELECT p.*, s.staff_name FROM payroll p JOIN staff s ON p.staff_id = [Link]
ORDER BY p.payment_date DESC");
$stmt->execute();
return $stmt->fetchAll(PDO::FETCH_ASSOC);
// Calculate total salaries
function calculateTotalSalaries() {
$conn = getDBConnection();
$stmt = $conn->prepare("SELECT SUM(salary) as total FROM staff");
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC);
return $result['total'] ?? 0;
// Get total students
function getTotalStudents() {
$conn = getDBConnection();
$stmt = $conn->prepare("SELECT COUNT(*) as total FROM students");
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC);
return $result['total'] ?? 0;
// Get total staff
function getTotalStaff() {
$conn = getDBConnection();
$stmt = $conn->prepare("SELECT COUNT(*) as total FROM staff");
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC);
return $result['total'] ?? 0;
// Get total fees collected
function getTotalFees() {
$conn = getDBConnection();
$stmt = $conn->prepare("SELECT SUM(amount_paid) as total FROM fees");
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC);
return $result['total'] ?? 0;
// Get recent activities
function getRecentActivities() {
return [
"New student Abdulmumini Adamu Musa registered",
"Result for First Term 2018/2019 published",
"Fee payment of ₦25,000 recorded for Daniel Julius",
"Staff payroll updated for November 2021"
];
Deployment Instructions
1. **Server Requirements**:
- Web server (Apache, Nginx)
- PHP 7.4 or higher
- MySQL 5.7 or higher
2. **Installation Steps**:
- Clone the repository to your web server
- Create a MySQL database and import the provided schema
- Configure database connection in `db_config.php`
- Set up necessary file permissions (storage, uploads)
- Install required PHP extensions (PDO, MySQL, GD for image processing)
3. **Configuration**:
- Set base URL in configuration
- Configure email settings for notifications
- Set up cron jobs for automated tasks (backups, reminders)
4. **Security Measures**:
- Change default admin credentials
- Set up HTTPS
- Implement regular backups
- Restrict file permissions
System Features
1. **Student Management**:
- Complete student bio-data recording
- Class assignment and promotion
- Registration number generation
- Parent/guardian information
2. **Academic Management**:
- Subject allocation
- Class and section management
- Teacher assignment
3. **Attendance Tracking**:
- Daily roll call
- Termly attendance summary
- Behavioral analysis reports
4. **Result Processing**:
- CAT, assignment, and exam scores entry
- Automatic grade calculation
- Result publication with PIN protection
- Report sheet generation
5. **Fee Management**:
- Fee allocation by class
- Payment recording with teller numbers
- Outstanding bills tracking
- Receipt generation
6. **Staff Management**:
- Staff bio-data
- Payroll processing
- Salary payment records
7. **Administrative Features**:
- User roles and permissions
- Audit trails
- System backup and restore
- PIN generation for result checking