Please support us by disabling ad blocker for smarttutorials.net ...

PHP Quiz Application Using jQuery Ajax MySQL and Bootstrap

Posted by & filed under Ajax, CSS, HTML5, JAVASCRIPT, JQUERY, MYSQL, PHP.

In this php quiz application i have combined the two of my previous tutorial and added few features to make this quiz application is useful one.

Note : You can refer my latest Quiz application
 
Responsive PHP Quiz Script

This PHP Quiz Application has following features.

1. This online Quiz Application has user login, registration and forget password functionality.
2. User can able to view their previous quiz results.
3. Each questions can have minimum two options or maximum of six options.
4. This online PHP Quiz Application has session message system to indicate success or failure of the user actions.
5. Removed old timer, and added new javascript or jQuery timer countdown with very few lines of code.
6. User has my account page where user can able to change his password.
7. This php quiz system has warning popup when user want to leave in mid of his current Quiz test.

 

 

PHP Quiz Application Using jQuery Ajax MySQL and Bootstrap

This are following two tutorials I had combined.

1. User registration and Login Using PHP5, MySQLi, jQuery and Bootstrap

2. Responsive Quiz Application Using PHP, MySQL, jQuery, Ajax and Twitter Bootstrap Part-3

Download PHP Quiz Script:

 

 

PHP Quiz Application Relational Database Design:

PHP Quiz Application Relational Database Design

PHP Quiz System Relational Database SQL Script:

Create Database and it’s tables using following SQL script

--
-- Database: `user_login`
--
CREATE DATABASE IF NOT EXISTS `user_login` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `user_login`;

-- --------------------------------------------------------

--
-- Table structure for table `categories`
--

CREATE TABLE IF NOT EXISTS `categories` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `category_name` varchar(100) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

-- --------------------------------------------------------

--
-- Table structure for table `questions`
--

CREATE TABLE IF NOT EXISTS `questions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `question_name` text NOT NULL,
  `answer1` varchar(250) NOT NULL,
  `answer2` varchar(250) NOT NULL,
  `answer3` varchar(250) NOT NULL,
  `answer4` varchar(250) NOT NULL,
  `answer5` varchar(250) NOT NULL,
  `answer6` varchar(250) NOT NULL,
  `answer` varchar(250) NOT NULL,
  `category_id` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;

-- --------------------------------------------------------

--
-- Table structure for table `scores`
--

CREATE TABLE IF NOT EXISTS `scores` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `category_id` int(11) NOT NULL,
  `right_answer` int(11) NOT NULL,
  `wrong_answer` int(11) NOT NULL,
  `unanswered` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `user_id` (`user_id`,`category_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

-- --------------------------------------------------------

--
-- Table structure for table `users`
--

CREATE TABLE IF NOT EXISTS `users` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(50) NOT NULL,
  `email` varchar(60) NOT NULL,
  `password` varchar(60) NOT NULL,
  `social_id` varchar(100) NOT NULL,
  `picture` varchar(250) NOT NULL,
  `created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `uuid` varchar(70) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `email` (`email`),
  KEY `login` (`password`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

Integrate User Login, Regisration and Forget Password Functionality in Quiz Application:

As I said I had integarted my previous tutorial on User registration and Login Using PHP5, MySQLi, jQuery and Bootstrap inΒ  this Online Quiz Using PHP. Please refer the above tutorial for detail integration.

If you may want integrate Social logins (i.e. Facebook, Twitter and Google Plus) in your Quiz Application, Please refer this following tutorial.

Facebook OAuth 2 Login Using PHP

Login with Google OAuth 2 Using PHP and MySQL

Sign in with Twitter OAuth API Using PHP

OAuth Login for Facebook Twitter and Google Plus Using PHP

PHP Quiz Script:

I had added few functionalities with this version of Quiz application, So please my previous tutorial on this making of PHP online Quiz Application Using jQuery, Ajax , MySQL and Twitter Bootrap.
This are my previous versions of this php quiz application.

Responsive Quiz Application Using PHP, MySQL, jQuery, Ajax and Twitter Bootstrap Part-3

Responsive Quiz Application Using PHP, MySQL, jQuery, Ajax and Twitter Bootstrap Part-2

Responsive Quiz Application Using PHP, MySQL, jQuery, Ajax and Twitter Bootstrap

Quiz application Using PHP, jQuery, Ajax, MySQL and HTML5

Timer Integration In Quiz Application:

I had removed timer in the previous version of Quiz application, and added new timer for this multiple choice quiz application with very few lines of jQuery script.

    var c = 60;
    var t;
    timedCount();
    function timedCount() {
    	var hours = parseInt( c / 3600 ) % 24;
    	var minutes = parseInt( c / 60 ) % 60;
    	var seconds = c % 60;
    	var result = (hours < 10 ? "0" + hours : hours) + ":" + (minutes < 10 ? "0" + minutes : minutes) + ":" + (seconds  < 10 ? "0" + seconds : seconds);
    	$('#timer').html(result);
        if(c == 0 ){
        	setConfirmUnload(false);
            $("#quiz_form").submit();
        }
        c = c - 1;
        t = setTimeout(function(){ timedCount() }, 1000);
    }

I had set my quiz application for 60 seconds. If you may want to change Quiz timings, then change in the following line.
For 10 Minutes

var c = 60*10;

For 20 Minutes

var c = 60*20;

For 1 hour

var c = 60*60;

PHP Flash Session Message Integration:

When user do some action in our application, we must properly communicate wheteher that action is success or failure to the user.

Assign your message in the Session like this…

session_start();
$_SESSION['success'] = 'Sample session message';

Display that message like this…

<?php if( isset( $_SESSION['error']) && !empty( $_SESSION['error'] )){ ?>
	<div class="message_error message_div">
		<p class="text-center"> <?php echo $_SESSION['error']; ?>  </p>
	</div>
<?php $s = 1;  ?>
<?php }elseif ( isset( $_SESSION['success']) && !empty( $_SESSION['success'] )){ ?>
<?php //print_r( $_SESSION );exit; ?>
	<div class="message_success message_div">
		<p class="text-center"> <?php echo $_SESSION['success']; ?> </p>
	</div>
<?php $s = 1; ?>
<?php }else{
	$s =0;
} ?>




<?php if($s){ $s = 0; ?>
	<script>
		$(document).ready(function(){
			$('.message_div').delay(5000).slideUp();
		});
    </script>
<?php } ?>

Once it displayed, we must unset that session using unset() function.

<?php unset($_SESSION['success'] ); unset($_SESSION['error']);  ?>  

.

Download Premium Only Scripts & 80+ Demo scripts Instantly at just 1.95 USD per month + 10% discount to all Exclusive Scripts

If you want any of my script need to be customized according to your business requirement,

Please feel free to contact me [at] muni[at]smarttutorials.net

Note: But it will be charged based on your customization requirement

Get Updates, Scripts & Other Useful Resources to your Email

Join 10,000+ Happy Subscribers on feedburner. Click to Subscribe (We don't send spam)
Every Email Subsciber could have access to download 100+ demo scripts & all future scripts.

  • Hello Muni,
    I have subscribed to your blog, please send me the download link of this script with the database.
    my email is mhayeor@gmail.com
    Thanks so much!

  • kasmad brebes

    Hello Muni,
    I have subscribed to your blog, please send me the download link of this script with the database.
    my email is brebeskasmad@gmail.com
    Thanks so much!

  • Vinti Thukral

    i have subscribed.. plz send me full code at vinti.thukral@gmail.com

  • Hello Muni, here Marcelo from Brazil ! I sent you an e-mail, no answer yet.

  • Carl Martin Haug

    Hello Muni. I paid to download this script. however, i did not get a download link, no notification mail no nothing. money is withdrawn. Please advise.

  • Cai Haoyang

    Hello Muni,
    I have subscribed, but there is on answer for days. So please send me the download link of this script with the database.
    My email is caihy.ps@gmail.com
    Thank you!

  • ThavaMani

    Hello muni
    how can i add review questions in final page guide me frd

  • Pavan.Maganti

    Working fine. Useful Post. Thanks.

  • scariest

    hi, any idea on how to make it a must for the user to pick an answer for each question. Thanks

  • ASLanimator

    I got it working all the way up to the last page – the questions do not display. I tried this in two browsers.
    Can you guide me? Where should I look to find the source of the problem? I THINK it might be in questions.php.

    http://aslxpress.net/cgi-bin/php-quiz/home

  • I have try, But doesn’t work. Can not import for table “users” and there wrong script

    Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in D:xampphtdocstrickphp-quizphp-quizClUser.php on line 91

    Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in D:xampphtdocstrickphp-quizphp-quizClUser.php on line 92

  • ASLanimator

    I found the issue:
    The user_login.sql file has the following line (190)
    `created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
    Change it to:
    `created` timestemp NOT NULL DEFAULT CURRENT_TIMESTAMP,

    That should allow you to import the sql file into your database.
    When I manually created the tables, I endeded up appending the new data to the first attempt with the problem line. My efforts to clean up duplicate records caused the problem with accessing the database – thus no questions displayed.

  • Rajibul Islam

    Hello Muni,
    I have subscribed to your blog, please send me the download link of this script with the database.
    my email is rajibul89@gmail.com
    Thanks so much!

  • Aural Recs Lanuza

    Hello my name is Angel Barbosa from Gto. Mx.. I need de source code for implement this quiz in a scholar project… if you can help me, send me the archives of this quiz to email: angelh2r@hotmail.com … tank you! grettings for all…

  • zhong_jiandan

    Hidup Wong Brebes!

  • hello sir muni . very useful tutorial πŸ™‚ i already subscribed to your blog . but i cannot download the script . please can you send me the download link ???? πŸ™ here’s my email almotimerh@gmail.com . thank you very much .

  • Kion Niebres

    Hello Muni,

    I have subscribed to your blog, please send me the download link of this script with the database.

    my email is breskion@gmail.com

    Thanks so much!

  • Puneeth

    Hi Muni,

    I wanted the same application to be done using MongoDB. I am new to it and conversion would be tricky. Could you please help me in getting this application working in MongoDB

  • Ardian Nugraha

    sir can you help me for send me a source code, to my email nugraha.ltd@gmail.com i dont get a link from subscribe

  • MYGO.GE

    Hello Muni,

    I have subscribed, but there is on answer for days. So please send me the download link of this script with the database.

    My email is vasgogna@gmail.com

    Thank you!

  • Carlos

    Hi Muni, my name is Carlos, please send me to source my email is afgames12@gmail.com i’m subscribe and nothing received source.

  • Mirsaid

    Please send it to my email: mirsaidalizade6@gmail.com

  • Selim Reza

    very good

  • Durgesh Dangi

    please send me this project patel95durgesh@gmail.com

  • Bashir abubakar

    hello muni please im getting this error code – Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in C:wamp64wwwnquiznquiznew_quizconfig.php on line 14 and this is my config.php code —

  • Eduard Aguilar

    incorrect password and user help

  • Xabier Aberasturi

    Hello Muni,
    I have subscribed to your blog, please send me the download link of this script with the database.
    my email is aberasturi@gmail.com
    Thanks so much!

  • Star Cosmoz

    Hello,

    I have subscribed, but there is on answer for days. So please send me the download link of this script with the database.

    My email is prince.chuhdhary@gmail.com

    Thank you!

  • Isn’t working

    please give us a download link…

  • Joshua

    I subscribed with no answer, please send it to me: joshua2@lynxsec.com

  • Joshua

    I have subscribed to your blog, please send me the download link of this script with the database.
    my email is joshua2@lynxsec.com

  • sent

  • Joshua

    I sent you a email showing a error.

  • Muhammad Shariq

    I have subscribed too, please send me download link

  • Laurence Silva

    I subscribed you using this email laurencesilva22@gmail.com. Send me the download link please.

  • Chera Robinson

    On my LAMP server it doesn’t work πŸ™ Register doesn’t work, login doesn’t work.. what can I do?

  • Jabyijit Gurung

    sir plz send me a source code for display wright and wrong answers…..
    i almost complete my project but jst stuck in to display wright and wrong ansers

  • montassar zarroug

    Hello,
    Just one question,
    If i have 2 answers corrects in the same questions what you can do ?
    Can you explain for me the modifications in your code please ?

    Thanks

  • dayo deeone

    This is a very lovely Project. Keep up the Good work.
    Pleas send me the Zip script, i have Subscribed to your blog.
    Email: ekundayo4live@gmail.com

  • Rameshwar Shashtri

    plz send me sour

    ce code

  • Rameshwar Shashtri

    please give us a download link…

Get Instant Script Download Access!