โ† Projects
PHP + MySQL Project 04

Student Management System

Build a complete student management system using PHP, MySQL, HTML and CSS. You will learn how to create, read, update and delete student records.

๐ŸŽฏ What You Will Build

This project is a complete CRUD-based Student Management System.

โž• Add
๐Ÿ‘ View
โœ๏ธ Edit
๐Ÿ—‘ Delete
๐Ÿ” Search

๐Ÿ›  Technologies Used

๐Ÿ“ Project Structure

student-management/
โ”‚
โ”œโ”€โ”€ tutorial.php
โ”œโ”€โ”€ index.php
โ”œโ”€โ”€ add.php
โ”œโ”€โ”€ edit.php
โ”œโ”€โ”€ delete.php
โ”œโ”€โ”€ style.css
โ””โ”€โ”€ database.sql
        

๐Ÿ—„๏ธ Step 1 โ€” Create Database

Open phpMyAdmin and create a database named:

aifa_php_lab

Your MySQL server is running on port 3307.

๐Ÿ—ƒ๏ธ Step 2 โ€” Create Students Table

Run this SQL query inside the aifa_php_lab database.

CREATE TABLE IF NOT EXISTS student_records (

    id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,

    full_name VARCHAR(100) NOT NULL,

    email VARCHAR(150) NOT NULL,

    phone VARCHAR(20) NOT NULL,

    course VARCHAR(100) NOT NULL,

    city VARCHAR(100) NOT NULL,

    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP

);
        

๐Ÿ”Œ Step 3 โ€” Database Connection

PHP connects to MySQL using the mysqli extension.

$host = "127.0.0.1";
$user = "root";
$password = "";
$database = "aifa_php_lab";
$port = 3307;

$conn = new mysqli(
    $host,
    $user,
    $password,
    $database,
    $port
);
        

๐Ÿ”„ Step 4 โ€” Understand CRUD

1

Create

Add a new student into the database using an HTML form and an INSERT query.

2

Read

Retrieve student records using a SELECT query and display them inside a table.

3

Update

Edit existing student information using an UPDATE query.

4

Delete

Remove a student record using a DELETE query.

โž• Step 5 โ€” Insert Student

The Add Student form sends information through POST.

INSERT INTO student_records
(full_name, email, phone, course, city)
VALUES (?, ?, ?, ?, ?)
        

We will use prepared statements to safely insert the data.

๐Ÿ‘ Step 6 โ€” Display Students

SELECT *
FROM student_records
ORDER BY id DESC
        

PHP will fetch the database records and display them inside a responsive table.

โœ๏ธ Step 7 โ€” Update Student

First we select the student using the ID. Then the existing information is displayed inside the edit form.

UPDATE student_records
SET
    full_name = ?,
    email = ?,
    phone = ?,
    course = ?,
    city = ?
WHERE id = ?
        

๐Ÿ—‘๏ธ Step 8 โ€” Delete Student

DELETE FROM student_records
WHERE id = ?
        

The student's ID identifies the exact record that should be removed.

๐Ÿ” Security Rules

๐Ÿงช Practice Tasks

  1. Add five students.
  2. Edit one student's course.
  3. Delete one student.
  4. Search for a student by name.
  5. Add a new field called gender.

๐Ÿš€ Ready to Build?

After understanding the tutorial, open the complete working project.

Run Complete Project โ†’