, , , , , ,

PHP Quiz Application Using jQuery Ajax MySQL and Bootstrap

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…

43
PHP Quiz Application Using jQuery Ajax MySQL and Bootstrap

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']);  ?>  

.

43 responses to “PHP Quiz Application Using jQuery Ajax MySQL and Bootstrap”

  1. Hello Muni,
    I have subscribed to your blog, please send me the download link of this script with the database.
    my email is [email protected]
    Thanks so much!

  2. 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 [email protected]
    Thanks so much!

  3. Vinti Thukral

    i have subscribed.. plz send me full code at [email protected]

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

  5. 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.

  6. 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 [email protected]
    Thank you!

  7. ThavaMani

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

  8. Pavan.Maganti

    Working fine. Useful Post. Thanks.

  9. scariest

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

  10. 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

  11. 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

  12. 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.

  13. 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 [email protected]
    Thanks so much!

  14. 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: [email protected] … tank you! grettings for all…

  15. zhong_jiandan

    Hidup Wong Brebes!

  16. 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 [email protected] . thank you very much .

  17. 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 [email protected]

    Thanks so much!

  18. 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

  19. Ardian Nugraha

    sir can you help me for send me a source code, to my email [email protected] i dont get a link from subscribe

  20. 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 [email protected]

    Thank you!

  21. Carlos

    Hi Muni, my name is Carlos, please send me to source my email is [email protected] i’m subscribe and nothing received source.

  22. Mirsaid

    Please send it to my email: [email protected]

  23. Selim Reza

    very good

  24. Durgesh Dangi

    please send me this project [email protected]

  25. 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 —

  26. Eduard Aguilar

    incorrect password and user help

  27. 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 [email protected]
    Thanks so much!

  28. 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 [email protected]

    Thank you!

  29. Isn’t working

    please give us a download link…

  30. Joshua

    I subscribed with no answer, please send it to me: [email protected]

  31. Joshua

    I have subscribed to your blog, please send me the download link of this script with the database.
    my email is [email protected]

  32. Joshua

    I sent you a email showing a error.

  33. Muhammad Shariq

    I have subscribed too, please send me download link

  34. Laurence Silva

    I subscribed you using this email [email protected]. Send me the download link please.

  35. Chera Robinson

    On my LAMP server it doesn’t work 🙁 Register doesn’t work, login doesn’t work.. what can I do?

  36. 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

  37. 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

  38. 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: [email protected]

  39. Rameshwar Shashtri

    plz send me sour

    ce code

  40. Rameshwar Shashtri

    please give us a download link…

  41. Randy Myers

    It works well, but how do I insert tests?

  42. Sercan

    I have subscribed too, please send me download link. My Email: [email protected]

Leave a Reply