Saturday, October 17, 2026 New tutorials published every day
Home
Tutorials
Core PHP PHP Course JavaScript React & Next.js Python WordPress Artificial Intelligence
Course
Lesson 1 — Start Here Course playlist Lesson notes & code
Projects
PHP Projects — all projects
More
About Contact Search Login
PHP Projects

Online Examination System - Full-Stack PHP & MySQL - Free Source Code

Explore a complete online examination system built with PHP and MySQL: admin panel, student portal, timed exam engine, 5 core tables and instant results.

Online Examination System - Full-Stack PHP & MySQL - Free Source Code

An Online Examination System built with PHP and MySQL lets a school, coaching institute or company create exams online, let students attempt them in a timed and monitored window, and show results the moment the test ends. This post introduces a complete, free, full-stack version of that system: what it includes, the modules it is made of, the technology behind it, its five core database tables, and the three ways you can put it online. If you want to use it, learn from it, or present it as a project, everything you need to understand it is here.

What Is This Project?

Most open-source exam systems sit at two extremes: heavy WordPress plugins or framework monoliths that take days to understand, or tiny demo scripts that cannot run a real test. This system sits in the sweet spot. It is lightweight, self-contained, written in pure PHP with a clean MVC structure, and still feature-complete enough for real use: an admin panel, a student portal, a proctored exam engine with a countdown timer, and instant results with analytics. Institutions use it for class tests and final exams, coaching centres use it for mock tests, and HR teams can use it for screening candidates. Developers and students use it to learn how a real multi-role PHP application is put together.

The Three Portals

Public homepage. Visitors see all published exams with live status indicators (Live, Upcoming or Ended), along with each exam's duration, total marks, passing criteria and negative marking information. Buttons change intelligently based on the visitor's role and the exam's status.

Admin panel. The dashboard shows the numbers that matter: total exams, total users, submissions, pass rate and average score. Admins manage exams in a card grid with live badges, manage questions with dynamic options and bulk CSV import, manage students, and explore results through a pass/fail donut chart and a score distribution bar chart, with a per-attempt answer review.

Student portal. Students browse available exams and start them in a fullscreen exam window. Answers auto-save the moment they are selected, a countdown timer submits the exam automatically when time runs out, and tab-switching is detected and logged. The result page appears instantly with the score, a correct/incorrect breakdown and a clear pass or fail verdict.

Online examination system in PHP and MySQL - illustration of an online exam on a computer monitor
The exam engine combines a countdown timer, auto-saved answers and instant results in one student-friendly screen.

Tech Stack

LayerTechnologyNotes
Backend languagePHP 8.1+No framework required
ArchitectureCustom MVCPure PHP, single front controller
DatabaseMySQL 8.0+PDO with prepared statements
FrontendBootstrap 5.3 + Vanilla JSResponsive, no build step
ChartsChart.js 4.4Pass/fail donut and score distribution
Icons and fontsBootstrap Icons, InterClean, readable interface
ServerApache / NginxPHP built-in server works for development

The whole application runs through one front controller, index.php, which routes every request to the right controller. That single decision keeps URLs clean and the code easy to follow. If the pattern is new to you, our guide on understanding the MVC concept in PHP explains it with examples.

Database: 5 Core Tables

TableKey columnsPurpose
usersid, name, email, password, role, statusAll roles in one table
examsid, title, duration, start_time, end_time, passing_marksExam configuration and scheduling
questionsid, exam_id, question_text, image_url, marksMCQ questions with an optional image
optionsid, question_id, option_text, is_correctChoices with a correct-answer flag
exam_attemptsid, user_id, exam_id, score, status, tab_switchesAttempts plus proctoring data
student_answersid, attempt_id, question_id, selected_option_id, marks_obtainedPer-answer scoring for review

All tables are tied together with foreign keys and ON DELETE CASCADE, so deleting an exam cleanly removes its questions, options and attempts instead of leaving orphan rows behind. Passwords are hashed with bcrypt, and every database query goes through PDO prepared statements, which is the correct defence against SQL injection attacks.

Module Breakdown

1. Authentication system. Session-based login and logout, bcrypt password hashing, a role-based guard that checks whether the current user is an admin, examiner or student, and a duplicate-email check during registration.

2. Exam management. Create, edit and delete exams with draft, published and completed states. Set the duration, total marks, passing marks, negative marking ratio and start/end times. An exam that is currently running shows a real-time LIVE badge.

3. Question management. Add MCQ questions with two to unlimited options using dynamic form fields, attach an image to a question, or bulk-import hundreds of questions at once from a CSV file. The question list supports AJAX pagination and live search, so big question banks stay manageable.

4. Exam engine (student side). Fullscreen enforcement when the exam starts, auto-save of every answer via AJAX, tab-switch and focus-loss detection with violations written to the database, a countdown timer with auto-submit, and an instant result page.

The CSV import format is simple: the first row is a header and is always skipped, the correct option must be A, B, C or D, options C and D may be left empty for True/False questions, and marks default to 1.0 when left blank. After installation, sign in with the default admin account (admin@example.com / password) and change that password immediately before using the system for anything real.

Three Ways to Deploy It

OptionDifficultyHow it works
Shared hosting (cPanel)EasiestUpload files in File Manager, create the MySQL database, import the SQL in phpMyAdmin, add the .htaccess rewrite rule
VPS / Ubuntu serverRecommendedApache + MySQL + PHP 8.1 stack, a virtual host, mod_rewrite enabled, free SSL from Let's Encrypt
DockerDev-friendlyThe included docker-compose file runs PHP-Apache and MySQL 8 with the schema imported automatically

Already completed in the system: the MVC architecture with a custom router, role-based authentication, full exam CRUD, dynamic MCQ options, bulk CSV import, the AJAX exam engine, tab-switch proctoring, results analytics and per-attempt answer review. Planned next: email notifications, exportable PDF/Excel reports, a tagged question bank, randomised question order per student, multi-language support and a REST API for a mobile app.

Who Should Build or Use It?

Build it if you are a PHP student who has finished basic CRUD projects and wants one substantial application that combines authentication, dashboards, charts, timers and security thinking. Use it if you run a class, a coaching batch or a small hiring process and need honest online testing without paying for an enterprise platform. And if you want to construct this kind of system yourself step by step, follow our step-by-step build guide for the online examination system, which walks through planning, database design and the exam engine in order.

Frequently Asked Questions

Is this online examination system really free?

Yes, the complete source code is free to download, study, modify and use for your institution or your college project. You only need free tools: PHP, MySQL and any standard local server or hosting plan. Most beginners use XAMPP, the free local server package from Apache Friends, which bundles all three together.

Which PHP and MySQL versions does it need?

It is built for PHP 8.1 or higher and MySQL 8.0 or higher. No framework and no Composer packages are required, which keeps installation simple on shared hosting.

How does the system stop students from cheating?

The exam runs in fullscreen, every tab switch or focus loss is detected and logged against the attempt, answers auto-save continuously, and the timer auto-submits at zero. Admins can see violation counts in the results.

Can I import questions in bulk instead of typing them?

Yes. Prepare a CSV file in the given format and import hundreds of questions in one go from the admin panel. A sample template is available in the Questions section.

What are the default login details after installation?

The admin account is admin@example.com with the password "password", and students register themselves from the public homepage. Change the admin password immediately after your first login.

Conclusion

A good examination system is really several small systems working together politely: accounts, scheduling, a careful exam engine and honest reporting. This PHP and MySQL project packages all of that in clean, framework-free code you can actually read end to end. Download it, run it locally, and then open the files and trace one exam from creation to result. That single exercise will teach you more about full-stack PHP than a shelf of tutorials.

Download File OnlineExaminationSystem.zip
Lavkush
Written by

Lavkush

Lavkush is a software developer with 5+ years of experience in the software industry, specialising in PHP and MySQL web development. Over the years he has built business websites, WordPress platforms and complete web applications — admin panels, login systems, dashboards and more. Through CodingCush, he turns that real project experience into simple, step-by-step tutorials with full working code, so students and beginners can learn by building real things, not just by reading theory. He also teaches on the Coding Cush YouTube channel, where his free PHP & MySQL Website Course builds a complete website, lesson by lesson.

0 Comments

Leave a Comment