Project overview
The Student Information System manages each student's profile: student number, full name, email address, course and year level. Staff can register students, browse the full list, open individual profiles, correct details and remove records, with every field validated before it is saved.
Problem it solves
Student details collected through forms and spreadsheets are often incomplete or mistyped. An email address without an @, or a year level of 0 or 5, breaks communication and reporting later on.
Key features
- Register, list, view, edit and delete student profiles
- Every field required, with all problems reported together
- Email addresses validated before they are stored
- Year level picked from 1 to 4 and checked again on the server
- The form keeps typed values when something needs fixing
Case-specific rule
A valid email and a year level from 1 to 4
All five fields are required, the email must be a valid address, and the year level must be a whole number from 1 to 4.
Database design
Database student_db, table students, InnoDB with utf8mb4.
| Column | Type | Rule |
|---|---|---|
| id | INT AUTO_INCREMENT | Primary key, generated automatically. |
| student_number | VARCHAR(30) | Required. Up to 30 characters. |
| full_name | VARCHAR(100) | Required. Up to 100 characters. |
| VARCHAR(100) | Required. A valid email address, up to 100 characters. | |
| course | VARCHAR(100) | Required. Up to 100 characters. |
| year_level | INT | Required. Exactly one of: 1, 2, 3, 4. |
From the code
The validation behind this case, exactly as written in create.php.
if (!filter_var($values['email'], FILTER_VALIDATE_EMAIL)) {
$errors[] = 'Enter a valid email address.';
}
if (!in_array($values['year_level'], ['1', '2', '3', '4'], true)) {
$errors[] = 'Year level must be 1, 2, 3, or 4.';
}Challenges and solutions
01
Catching bad data before it is saved
Challenge encountered
Profiles are only useful when every field is present and the email and year level make sense, but people make typos.
Solution implemented
Each field is trimmed and checked: filter_var with FILTER_VALIDATE_EMAIL validates the email, and a strict in_array check accepts only year levels 1 to 4.
02
Not making people start over
Challenge encountered
A form that clears itself after one mistake forces staff to retype everything.
Solution implemented
Sticky form values: after a failed save, every field is refilled with what was typed, safely escaped, and every error is listed at the top.
Outcome and impact
Clean, consistent student profiles, with validation that explains exactly what to fix.
Every PHP file in the project passed syntax checking before submission.
- Files delivered
- 8
- PHP pages
- 6
- Table columns
- 6
- Sample records
- 3
Project files
Delivered in the required eight-file format, ready to drop into XAMPP.
config.phpOpens the PDO connection to the database, with exceptions turned on for errors.index.phpLists every record, newest first, with View, Edit and Delete links on each row.create.phpValidates a new record, saves it with a prepared INSERT, then redirects to the list.view.phpShows one record after checking that its ID is a positive whole number.edit.phpLoads an existing record, validates the changes and saves them with a prepared UPDATE.delete.phpShows a confirmation page, then deletes the record only on a confirmed POST.database.sqlCreates the database and table, then inserts three fictional sample records.README.mdSetup steps for XAMPP and phpMyAdmin, plus the feature list and local URL.
Secure by default
The same six practices protect all five examination cases.
- Prepared statementsEvery query runs through PDO prepared statements with named placeholders, so typed input never becomes part of the SQL.
- Escaped outputEvery value passes through htmlspecialchars with ENT_QUOTES and UTF-8 before it reaches the page, which blocks script injection.
- POST-only changesCreating, editing and deleting only happen on POST requests, and a delete needs an explicit confirmation first.
- Safe record IDsIDs must be positive whole numbers. A missing or invalid record returns a 404 with a clear Record not found page.
- Post, redirect, getAfter a successful save the page redirects to the list, so refreshing the browser never submits the form twice.
- Helpful validationFailed saves list every problem at once and keep what was typed, so nobody has to fill in the form again.
See it working
Add, edit and delete records in the live demo, and watch each prepared statement as it runs.