php - Why Can't I Pass a String? -


i'm trying quiz program work in php. until now, i've had little problem getting code write work. however, time, can't seem string pass next page of form. basic idea trivia program. random question retrieved, user answers question, program checks see if answer right. eventually, program keep score, haven't got far yet because can't seem check answer against question. can't figure out i'm going wrong.

if there's answer this, i'm sorry, missed it. thing saw said use javascript, beyond current skillset. thanks.

the code:

<!doctype html> <html lang="en-us">  <head> <!--link--> <meta charset="utf-8" /> <title>sports trivia</title> </head>  <body> <form> <?php>      extract($_request);      include("triviaquestions.php");       //functions      //display next question template provided dan brekke      function nextquestion($trivia,&$used)      {                          $num = rand(0,count($trivia)-1);           while ($used[$num]);           $used[$num] = true;           reset($trivia);           ($i = 0; $i < $num; $i++)                next($trivia);           return key($trivia);      }       function displayquestion($trivia,$count,&$used,$question)      {           if ($count < count($trivia))           {                $questionnum = $count+1;                 echo <<< here                <h3>question $questionnum:</h3>                <h3>$question</h3> here;           }           else                $question = "you've reached endzone!";      }       function displaybuttons()      {           echo <<< here           <p>           <input type="submit" name="button" value="next question" />           <input type="submit" name="button" value="quit" />           </p> here;      }       function passdata($trivia,$count,$used)      {           echo "<input type='hidden' name='count' value='$count'>";           ($i = 0; $i < count($trivia); $i++)                echo "<input type='hidden' name='used[$i]' value='$used[$i]'>";      }       if ($button == null || $button == "new game")      {           //variables           $used = null;           $count = 0;           $correct = 0;             echo <<< here           <h1>sports trivia!</h1>           <h3>welcome sports trivia. enter name , click play begin!</h3>           <h3>name:           <input type="text" name="name" autocomplete="off" autofocus="on">           </h3>           <input type="submit" name="button" value="play" />           <input type="submit" name="button" value="display scores" />           <br /><br />           <a href="..">back home</a> here;           //experimenting, since don't know how works           serialize($trivia);           serialize($used);      }      else      {           if ($button == "play")           {                $question = nextquestion($trivia,$used);                displayquestion($trivia,$count,$used,$question);                echo <<< here                <input type="text" name="answer" autocomplete="off" autofocus="on" />                <p>                <input type="submit" name="button" value="enter" />                </p> here;           }            else if ($button == "enter")           {                echo $question;           }      }      echo <<< here      <input type="hidden" name=$helloworld /> here; ?> </form> </body> </html> 


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -