School Management System Project With Source Code In Php Info

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';

$user_stmt = $pdo->prepare("INSERT INTO users (username, password, role) VALUES (?, ?, ?)");
$user_stmt->execute([$username, $hashed_password, $role]);
$user_id = $pdo->lastInsertId();
// Insert into students table
$stmt = $pdo->prepare("INSERT INTO students (user_id, admission_no, first_name, last_name, dob, class_id, section_id) 
                       VALUES (?, ?, ?, ?, ?, ?, ?)");
$stmt->execute([$user_id, $_POST['admission_no'], $_POST['first_name'], $_POST['last_name'], 
                $_POST['dob'], $_POST['class_id'], $_POST['section_id']]);
$success = "Student added successfully!";

?>

Here are essential tables for the system: school management system project with source code in php


<?php
session_start();
if (!isset($_SESSION['student_id'])) 
    header('Location: ../login.php');
    exit();
include('../config/db_connection.php');

$student_id = $_SESSION['student_id'];

$query = "SELECT subjects.subject_name, exam_marks.marks_obtained, exam_marks.exam_name FROM exam_marks JOIN subjects ON exam_marks.subject_id = subjects.id WHERE exam_marks.student_id='$student_id'"; File: modules/admin/add_student

$result = mysqli_query($conn, $query); ?>

<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> Here are essential tables for the system: