Online Examination System In PHP With Source Code

This guide walks you through building an Online Examination System in PHP and MySQL from the ground up, an online quiz and exam project with automatic scoring, complete with source code. Instead of only downloading it, you will understand how each part works: the database schema, how questions are stored, how a student takes an exam, how answers are scored automatically, and how results are shown. That understanding is what turns a downloaded project into something you can explain in a viva, extend for an assignment, or showcase in your portfolio.

Want the full source code? The complete online examination system in PHP, with all source files and the MySQL database, is available to download and run locally. Follow the guide below to understand what each part does before or after you grab it.
Jump to download & setup
What you’ll learn
  1. What an online examination system does
  2. The database schema (users, exams, questions, results)
  3. How questions are stored and managed
  4. How a student takes an exam
  5. Automatic scoring: the core logic
  6. Results, the admin panel, and login
  7. Setup: running it on your machine
  8. How to extend it for your own project

1. What an online examination system does

An online examination system lets an institution conduct quizzes and exams over the web. An admin or teacher creates exams and adds questions with their correct answers, students log in and take an exam by answering the questions, and the system scores their answers automatically and shows the result. It removes paper, manual marking, and waiting, which is why it is one of the most useful and popular student projects. Building one in PHP and MySQL exercises every core skill, database design, CRUD, relationships between tables, authentication, sessions, and the scoring logic that compares answers, in a context every student knows from the inside.

The version in this guide includes exam and question management, student login, taking a timed exam of multiple-choice questions, automatic scoring, result display, and an admin panel. That is enough to be a complete, demonstrable project while staying clear enough to fully understand.

2. The database schema

The schema is the backbone of the project, so it is the best place to start. The online examination system uses these core tables.

TableWhat it storesKey columns
usersStudents and the adminid, name, email, password, role
examsEach exam or quizid, title, duration, total_marks
questionsQuestions with options and the correct answerid, exam_id, question, option_a, option_b, option_c, option_d, correct_option
resultsA student’s score for an examid, user_id, exam_id, score, taken_date

The relationships are the key idea. An exam has many questions (each question’s exam_id links it to its exam), and a result links a student to the exam they took with their score. The crucial design point is the correct_option column on each question: storing the right answer alongside the question is what makes automatic scoring possible later. Understanding this single diagram is understanding most of the project, because every screen reads or writes one of these tables.

The most important schema decision here is storing the correct answer with each question. It means the system already knows the right answer when a student submits, so scoring is just a comparison. Being able to point to this and explain how it enables automatic marking is exactly the kind of insight that impresses an examiner.

3. How questions are stored and managed

The admin creates an exam and then adds questions to it. Each question is a row with the question text, four options, and which option is correct. Adding a question, with values from a form, uses a prepared statement:

// add a multiple-choice question (simplified)
$stmt = $conn->prepare(
  "INSERT INTO questions
   (exam_id, question, option_a, option_b, option_c, option_d, correct_option)
   VALUES (?, ?, ?, ?, ?, ?, ?)"
);
$stmt->bind_param("issssss", $examId, $q, $a, $b, $c, $d, $correct);
$stmt->execute();

The prepared statement with bind_param, rather than dropping form values straight into the SQL string, is how you prevent SQL injection, a core security habit in PHP and a detail that marks a project you understand rather than one you copied. The correct_option stores something like the letter of the right answer, which the scoring step will compare against the student’s choice.

4. How a student takes an exam

A logged-in student picks an exam, and the system loads its questions with a SELECT where exam_id matches. The questions are shown as a form with radio buttons for the four options. Importantly, the correct answer is never sent to the browser, only the question and its options, so a student cannot peek at the answer in the page source. When the student submits, their chosen options for every question are sent back to the server, where the scoring happens. A timer, often a small piece of JavaScript counting down the exam’s duration, can auto-submit when time runs out.

5. Automatic scoring: the core logic

This is the heart of the project. When the student submits, the server loops over the exam’s questions, compares each submitted answer against the stored correct_option, and counts how many match. That count is the score.

// score a submitted exam (core idea)
$score = 0;
$questions = $conn->query("SELECT id, correct_option FROM questions WHERE exam_id = $examId");
while ($q = $questions->fetch_assoc()) {
  $submitted = $_POST['answer'][$q['id']] ?? '';
  if ($submitted === $q['correct_option']) {
    $score++;
  }
}
// save the result
$stmt = $conn->prepare(
  "INSERT INTO results (user_id, exam_id, score, taken_date)
   VALUES (?, ?, ?, NOW())"
);
$stmt->bind_param("iii", $userId, $examId, $score);
$stmt->execute();

Notice that scoring happens entirely on the server, never in the browser, because the browser was never trusted with the correct answers. This is both the central feature and an important security lesson: marking must be done where the student cannot tamper with it. Being able to walk an examiner through this loop, load correct answers, compare each submission, count matches, save the result, demonstrates that you understand the full exam lifecycle, not just isolated pieces.

6. Results, the admin panel, and login

After scoring, the student sees their result, and it is saved in the results table for later. The student can view their past results, and the admin can see all students’ results, each a SELECT, often with a JOIN to show names and exam titles instead of IDs. The whole system sits behind a login that verifies a hashed password with password_verify and uses the role column to separate students from the admin. The admin panel manages exams, questions, and results, all built on the same query patterns you now understand.

7. Setup: running it on your machine

To run the project locally you need a PHP environment with MySQL, most commonly XAMPP on Windows or its equivalent on Mac and Linux. The steps are:

  1. Install XAMPP and start the Apache and MySQL services.
  2. Copy the project folder into the htdocs directory.
  3. Open phpMyAdmin, create a database, and import the included .sql file to create the tables.
  4. Open the project’s config file and set the database name, user, and password to match your setup.
  5. Visit the project in your browser through localhost and log in with the default admin credentials in the guide.
Download the full source code
The complete online examination system in PHP with MySQL, including all source files and the database, is ready to download and run by following the steps above.
Download source code

Replace this link with your actual download URL.

8. How to extend it for your own project

Assignments and portfolios reward what you add, not what you copied. Because you now understand the schema and the scoring logic, here are natural extensions you can build and explain:

  • Negative marking: subtract marks for wrong answers, a small change to the scoring loop.
  • Question categories and random selection: pull a random subset of questions so each attempt differs.
  • Review answers: after the exam, show which questions were wrong and the correct answer.
  • Per-question marks: let questions carry different weights instead of one mark each.
  • Leaderboard: rank students by score for an exam using ORDER BY on the results table.

Each is a small, well-scoped addition that demonstrates real understanding, exactly what turns a standard download into a project you can defend and be proud of.

Frequently asked questions

What is an online examination system in PHP?

It is a web application for conducting quizzes and exams online with automatic scoring, built with PHP and MySQL. It is a popular student project because it covers database design, CRUD, authentication, sessions, and the answer-comparison scoring logic in one realistic system.

What database tables does it use?

The core schema has four tables: users, exams, questions (each linked to an exam, with its correct answer stored), and results. Storing the correct answer with each question is what makes automatic scoring possible.

How does automatic scoring work?

When a student submits, the server loops over the exam’s questions, compares each submitted answer to the stored correct option, and counts the matches. Scoring is done on the server so students cannot see or tamper with the correct answers.

Can I use this as my college or university project?

Yes. It is well suited as an academic project, and because this guide explains the database design, how an exam is taken, and how scoring works, you can confidently answer questions in a viva. Adding one of the suggested extensions makes it stronger still.

Is the source code free to download?

Yes, the full online examination system source code is available to download for free using the link in the download section above.

Online examination system focuses on creating effective assessment questions and focusing on exam’s feedback delivery to students. In the paper we present techniques that are pertinent to the elements of assessment process: answers submission, computerized grading, and feedback after submission.

As the modern organizations are automated and computers are working as per the instructions, it becomes essential for the coordination of human beings, commodity and computers in a modern organization. The administrators ,instructor,Students who are attending for online examination can communicate with the system through this projects, thus facilitating effective implementation and monitoring of various activities of Online Examinations like conducting Exams as per scheduled basis and delivering result to that particular use or student.And the details of students who attempted Online Examination are maintained at administrator.

Online examination system is used to conduct online  examination.  The students can sit at individual terminals and login to write the exam in the given duration. The questions have to be given to the students.This application will perform correction, display the result immediately and also store it in database. This application provides the administrator with a facility to add new exams.This application provides the  Instructor  add questions to the exam, modify questions in the exam in a particular exam. This application takes care of authentication of the administrator,Instructor as well as the student. The objective of the Online Examination  Tool is to provide better information for the users of this system for better results for their maintainence in student examination schedule details and grading details. A report with all necessary written contents of this project is also available within the project.

Technology Used: HTML, CSS, PHP, JavaScript, MYSQL

Registration Page

Home Page(Courses)

MODULES:

1:ADMIN  MODULE

2.INSTRUCTOR MODULE

3.STUDENT MODULE

1.ADMIN MODULE:

1.:REGISTER

2.LOGIN

3.CHANGE PASSWORD&FORGOTPASSWORD

 4.STUDENT -MODIFING DETAILS

5.DEPARTMENTS-ENTERING/MODIFYING DETAILS

 6.INSTRUCTOR DETAILS-MODIFYING DETAILS

2.INSTRUCTOR MODULE:

1.REGISTER

2. LOGIN

3CHANGE PASSWORD&FORGOT PASSWORD

4.ADD QUESTIONS-DEPARTMENTS VERIFING.

5.UPDATE QUESTIONS -DEPARTMENTS VERIFING

6.CREATE EXAMS

7.UPDATE EXAMS

8.VIEW  EXAM DETAILS- VIEW NO OF REGISTERED STUDENTS

 VIEW NO OF ATTENDED STUDENTS

9.EVALUATE QUESTION:MULTIPLE CHOICE

3.   STUDENT DETAILS:

1.REGISTER

2.LOGIN

3.TAKE EXAM- MULTIPLE CHOICE

                                TRUE/FALSE

4. SEE EXAM RESULTS

5.LOGOUT

Ranking Page

INSTRUCTIONS:

– Download and extract files

– Create new database named ‘project’

– Import the ‘project.sql’ file

– Open the directory using XAMPP

(Note: Read the ‘Readme.txt’ file for other details)

Installation Steps:

To run the project, you will need to download XAMPP or WAMP server on your PC. First download and setup your own local server then download the zip file. Unzip the .zip file using any zip programs such as Winrar or 7Zip. After extracting, copy the project folder to the “C:/wamp/www/” or “C:/xampp/htdocs/” destination folder. After you are done, open your browser and type the URL for example. localhost/…..system.

If you didn’t understand the installation and setup process, follow this video:

FIND MORE on this site

DOWNLOAD Online Examination System In PHP With Source Code FOR FREE

1 thought on “Online Examination System In PHP With Source Code”

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top