den måde de har lavet det på hos jetpunk er med javascript (så er lidt nemt at snyde)
da alle sprøgsmål og svar står i kildekoden
- q.answers = {
- "1" : new Answer("1", ["Boardwalk","What is the most expensive property in the U.S. version of Monopoly?"], ["BOARDWALK$"]),
- "2" : new Answer("2", ["Charles I","Which English King was beheaded during the English Civil War?"], ["^(KING)?CHARLES"]),
- "3" : new Answer("3", ["Star Trek: The Next Generation","Which television show featured the Holodeck?"], ["^STARTREK","THENEXTGENERATION$"]),
- "4" : new Answer("4", ["Wedding Dresses","Vera Wang is most famous for designing what?"], ["WEDDING(DRESS|GOWN)"]),
- "5" : new Answer("5", ["Cornucopia","What is also referred to as a horn of plenty?"], ["CORN[AEIOU]COP[EI]A$"]),
- "6" : new Answer("6", ["Sherlock Holmes","Dr. House is partly inspired by which famous literary character?"], ["^SHERLOCK","^HOLMES"]),
- "7" : new Answer("7", ["Webster","Which TV show was similar to Diff'rent Strokes?"], ["^WEBSTER"]),
- "8" : new Answer("8", ["Mount Vesuvius","Which volcano destroyed the city of Pompeii"], ["^(MOUNT|MT)?V[AEI]SUV[EI][OU]+S"]),
- "9" : new Answer("9", ["Justin Bieber","Which celebrity is known as The Bieb?"], ["B[EI]+BER$"]),
- "10" : new Answer("10", ["Hadrian","Who built a wall to separate Scotland and England?"], ["^HADRI[AE]N"]),
- "11" : new Answer("11", ["Andrew Lloyd Webber","Who wrote the Phantom of the Opera musical?"], ["WEBBER$"]),
- "12" : new Answer("12", ["Lilith","What was the first name of Frasier's ex-wife?"], ["^LIL+[EI]TH"]),
- "13" : new Answer("13", ["1331","What is 11 cubed?"], ["^1331"]),
- "14" : new Answer("14", ["Oak","What type of tree grows from an acorn?"], ["^(AN)?OAK"]),
- "15" : new Answer("15", ["Marilyn Monroe","Who sang <i>Happy Birthday, Mr. President</i>?"], ["MONROE$"]),
- "16" : new Answer("16", ["The Iditarod","What is the world's most famous dog sled race?"], ["^(THE)?IDIT[AEIO]ROD"]),
- "17" : new Answer("17", ["Colombia","Juan Valdez advertises the coffee of which country?"], ["^COL[OU]MBIA"]),
- "18" : new Answer("18", ["Dr. Evil","Who requested sharks with frickin' laser beams?"], ["^(DOCT[EO]R|DR)EVIL"]),
- "19" : new Answer("19", ["Roswell","Which New Mexico city is associated with a 1947 UFO crash?"], ["^ROSWELL"]),
- "20" : new Answer("20", ["Socks","What was the name of the Clinton family cat?"], ["^SOCKS"])
- };
hvis du ønsker at lave det med javascript findes der sikkert et jquery plugin til det
(jeg kender dog ikke lige et jeg kan anbefale), ellers kan du kigge hvordan de har lavet det på jetpunkt.
hvis du ikke vil have folk kan læse svarne i koden, skal du lave det med PHP enten i form af en html form du submitter og ser om svaret er korrekt via php, eller med javascript/ajax som kalder en php fil og ser om svaret er passer.
du kan prøve at lave en html form og modtage det med php og udskrive det du modtager.
form:
- <form action="svar.php" method="post">
- hvad er 2+2?
- <input name="svar" />
- <input type="submit" name="doSubmit" value="Send svar" />
- </form>
svar.php
- <?php
- if(isset($_POST["doSubmit"])){
- var_dump($_POST); //udskriv hele post arrayet.
- $svar = $_POST["svar"];
- if($svar == "4"){
- echo "jaah!");
- }else{
- echo "prøv igen";
- }
- }
- ?>
her kan du se at $_POST["svar"] indeholder det du skrev i text feltet, så kan du tjekke med nogen if'er eller switch's om svaret passer
http://pt2.php.net/manual/en/control-structures.if.phphttp://pt2.php.net/manual/en/control-structures.switch.phpmen dem kender du jo nok fra javascript
du kan evt udvide med svar fra en database, men ved ik hvor meget php du kan, så tror jeg stopper her.