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