A simple quiz _ PHP Tutorial

Source: Internet
Author: User
A simple small game to guess words. I forgot where I saw this game. I wrote it right before I went to bed. there was no good idea, and there was no pursuit of style or anything. I used the SESSION to work with AJAX, I forgot where I saw this game. I wrote it right before I went to bed,
There is no good idea, and there is no pursuit of style or anything,
The SESSION is used in combination with AJAX,
CAPTCHA farmers, for advice and guidance,
PS: No optimization. do not spray it,
Copy the local file to run the task,



 Script function Ajax (recvType) {var aj = new Object (); aj. recvType = recvType? RecvType. toUpperCase (): 'html'; aj.tar getUrl = ''; aj. sendString = ''; aj. resultHandle = null; aj. createXMLHttpRequest = function () {var xmlHttp = false; if (window. XMLHttpRequest) {xmlHttp = new XMLHttpRequest ();} else if (window. activeXObject) {try {xmlHttp = new ActiveXObject ("Msxml2.XMLHTTP");} catch (error1) {try {xmlHttp = new ActiveXobject ("Microsoft. XMLHttp ") ;}catch (error2) {xmlHttp = false ;}}} Return xmlHttp;} aj. XMLHttpRequest = aj. createXMLHttpRequest (); aj. processHandle = function () {if (aj. XMLHttpRequest. readyState = 4) {if (aj. XMLHttpRequest. status = 200) {if (aj. recvType = "HTML") {aj. resultHandle (aj. XMLHttpRequest. responseText);} else if (aj. recvType = "XML") {aj. resultHandle (aj. XMLHttpRequest. responseXML) ;}}} aj. get = function (targetUrl, resultHandle) {aj.tar getUrl = targetUrl; if (resu LtHandle! = Null) {aj. XMLHttpRequest. onreadystatechange = aj. processHandle; aj. resultHandle = resultHandle;} if (window. XMLHttpRequest) {aj. XMLHttpRequest. open ("get", aj.tar getUrl); aj. XMLHttpRequest. send (null);} else {aj. XMLHttpRequest. open ("get", aj.tar getUrl, true); aj. XMLHttpRequest. send () ;}} return aj ;}script var ajax = Ajax (); function select (v) {document. getElementById (v ). style. display = 'none'; ajax. g Et ("guess. php? Op = ajax & k = "+ v, function (r) {var t = r. split ("|"); document. getElementById ('word '). innerHTML = t [0]; if (t [1] = 1) {document. getElementById ('select '). style. display = 'none'; document. getElementById ('result '). innerHTML = 'success';} else if (t [1] = 2) {document. getElementById ('select '). style. display = 'none'; document. getElementById ('result '). innerHTML = 'failed' ;}});} function check (v) {ajax. get ("guess. php? Op = start & k = "+ v, function (r) {window. location. href ="
 ";}) ;}Script
 Easy: wrong 10
'; Echo'Normal: wrong 5
'; Echo'Hard: wrong 3
';} Else {// echo $ word; echo "a maximum of errors can be guessed". $ _ SESSION ['num']. "times"; echo"
"; Echo"

"; Echo output ($ guess_word); echo"

"; Echo'
'; Echo'

'; For ($ I = ord ('A'); $ I <= ord ('Z'); ++ $ I) {echo "\ n "; $ letter = chr ($ I); echo ''. $ letter. '';} echo'

'; Echo'
'; Echo'
'; Echo'

'; Echo'
'; Echo'
'; Echo 'restart';}?>

Sorry, there is no good idea, and there is no pursuit of style or something. The SESSION is used in combination with AJAX. I hope you can provide suggestions and guidance...

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.