Php+mysql to develop a simple online problem-solving system

Source: Internet
Author: User
This article mainly introduces the Php+mysql development of a simple online question bank, online to do the problem system, has a certain reference value, now share to everyone, the need for friends can refer to

Question Bank, for educational institutions, schools, online education, is very necessary, there are many third-party online database system, but this case, will let people who need to understand the development of the idea, in fact, is very simple, is a form verification, database validation.

1. Build form data first

2. Submit the form data to the form verification page via get or post, and match the database

3. Return result, correct or wrong answer

To build a form:

index.php

<! DOCTYPE html>

Form Receive

check.php

<?phpheader ("Content-type:text/html;charset=utf-8");//Get Database configuration Require_ Once ("config.php");//Connect Database $con = mysql_connect ($host, $username, $password);//Set the database character set mysql_query ("Set NAMES UTF8") ;//Query Database mysql_select_db ($db, $con);//Get Data $xuanxiang = $_get["Xuanxiang"]; $id = $_get["id"];if (Empty ($xuanxiang)) {EC Ho "<script>alert (' please choose an answer! '); History.go ( -1);</script> ";}    else{//Query Database $result = mysql_query ("select * from $TB WHERE id =". $id);        while ($row = Mysql_fetch_array ($result)) {$true = $row ["true"];        $next _id = $id +1; if ($xuanxiang = = $true) {echo "<script>alert (' Correct! Get 5 points!        location.href= ' next.php?page= $next _id ';</script> "; }else{echo "<script>alert (' Wrong! Buckle 5 points!        '); History.go ( -1);</script> "; }}}?> 

Database configuration

config.php

<?php//configuration file-by tanking$host= "Database Address"; $username = "Account"; $password = "password"; $db = "database name"; $TB = "table name";? >

next.php

next question

<! DOCTYPE html>

Database structure

Title--------Title
Answer_a-----Answer A
Answer_b-----Answer B
Answer_c-----Answer C
Answer_d-----Answer D
True---------correct answer
Score--------Score


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.