Jump to content

gdanelian

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Everything posted by gdanelian

  1. Hello all... I have set up a quiz question:<form action="http://********/quiz2.php" method="get" class="a1"> <p align="center">WELCOME TO MY COURSEWORK QUIZ...</p> <p align="center"><strong>Question One: Which of the following was originally designed for producing dynamic web pages </strong></p> <div align="center">The Universe <input type="radio" name="ANSWER" value="The Universe" > <br> XHMTL <input type="radio" name="ANSWER" value="XHMTL" > <br> CSS <input type="radio" name="ANSWER" value="CSS" > <br> PHP <input type="radio" name="ANSWER" value="PHP" > <br> <input type="submit" value="SUBMIT YOUR ANSWER"> </div> </form> I want to include a link called "Do you need help? Click here for a 50/50" which when clicked two of the radio buttons become hidden. How do I do this? I have seen some funky things with XML/javascript but my quiz is written in xhtml format and is linked to php functions using $_GET All help welcome! Thank you
  2. Hello all... I have set up a quiz question:<form action="http://********/quiz2.php" method="get" class="a1"> <p align="center">WELCOME TO MY COURSEWORK QUIZ...</p> <p align="center"><strong>Question One: Which of the following was originally designed for producing dynamic web pages </strong></p> <div align="center">The Universe <input type="radio" name="ANSWER" value="The Universe" > <br> XHMTL <input type="radio" name="ANSWER" value="XHMTL" > <br> CSS <input type="radio" name="ANSWER" value="CSS" > <br> PHP <input type="radio" name="ANSWER" value="PHP" > <br> <input type="submit" value="SUBMIT YOUR ANSWER"> </div> </form> I want to include a link called "Do you need help? Click here for a 50/50" which when clicked two of the radio buttons become hidden. How do I do this? I have seen some funky things with XML/javascript but my quiz is written in xhtml format and is linked to php functions using $_GET All help welcome! Thank you
  3. I put this back in and it works a dream! : ) && $_COOKIE['q'.$n]) what does this extra bit mean? Cheers!
  4. PAGE 2: Your answer is The Universe Incorrect Your current score = 0Answers so far: Array ( [1] => 0 ) PAGE 3: Your answer is Michael Jackson Incorrect Your current score = 1Answers so far: Array ( [1] => 1 [2] => 0 ) PAGE 4: Your answer is Toast Incorrect Your current score = 2Answers so far: Array ( [1] => 1 [2] => 1 [3] => 0 ) PAGE 5: Your answer is George W Bush Incorrect Your current score = 3Answers so far: Array ( [1] => 1 [2] => 1 [3] => 1 [4] => 0 ) FINAL PAGE: Your answer is Monitor Incorrect!!! Your final score = 4Answers so far: Array ( [1] => 1 [2] => 1 [3] => 1 [4] => 1 [5] => 0 ) !? thank you (again!)
  5. Thank you very much for the explanation it makes a lot more sense now. However it does not work correctly. If you answer the questions incorrectly it is still adding to the score. It works fine if you answer them all correctly...top score is 5, well done etc. Am i a) use the wrong echo (I am using echo "Your current score = "; // echo $score;) Or b) is the cookie just adding 1 anyway despite it being set to only add one if correct. Thanks yet again. Ill try and get the beer and girls over to you asap...
  6. Hello again! I am still having trouble getting the cookie to work. Do I have to change any part of the cookie code for different pages? i.e. on page two do I have to change something in the cookie? Also what if the user presses the back button and answers again...will this mess the cookie up. Finally can you tell me what the different parts of the cookie code mean? <?php $num = 1; $correct = 0; if($_GET['ANSWER'] == "PHP") $correct = 1; //Load old answers $answers = array(); for($n = 1;$n <= 4;$n++){ if(isset($_COOKIE['q'.$n]) && $_COOKIE['q'.$n]) $answers[$n] = 1; } //Add new answer $answers[$num] = $correct; setCookie('q'.$num,$correct); //Get their score $score = array_sum($answers); ?> Also does the cookie need to be on all the pages including page one? Sorry to be such a pain!!! Thank you
  7. FIXED! Instead of looking at your code I read it and attempted to understand what was going on... that helped me! How can I thank you enough?!
  8. Hello again, I tested the code you gave me for the quiz On the 5th and final page I use echo $score; Unfortunately it print '0' no matter how many correct answers I give. I took the following code out of the second page: //Load old answers $answers = array(); for($n = 1;$n <= 4;$n++){ if(isset($_COOKIE['q'.$n]) && $_COOKIE['q'.$n]) $answers[$n] = 1; } And the score became '1' On the 5th page I want to print the number of correct answers...is there anymore help going? I can't believe how kind you have been so far!!! Thanks
  9. You are awesome! I am going to try this and report back. THANK YOU SO MUCH! Best Wishes
  10. THIS IS THE FIRST PAGE OF THE QUIZ <%@LANGUAGE="JAVASCRIPT" CODEPAGE="65001"%> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <html> <head><title>The Quiz</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css"> <!-- body,td,th { color: #FFF; } body { background-color: #000; } </style></head> <body> <a href='' onMouseOver='window.alert("The correct answer is either PHP or CSS, good luck")'>Would you like a 50/50?</a> <?php ?> <form action="http://www.00000000.ac.uk/~08007934/php/quiz2.php" method="get" class="a1"> <p align="center">WELCOME TO MY COURSEWORK QUIZ...</p> <p align="center"><strong>Question One: Which os the following was originally designed for producing dynamic web pages </strong></p> <div align="center">The Universe <input type="radio" name="ANSWER" value="The Universe" > <br> XHMTL <input type="radio" name="ANSWER" value="XHMTL" > <br> CSS <input type="radio" name="ANSWER" value="CSS" > <br> PHP <input type="radio" name="ANSWER" value="PHP" > <br> <input type="submit" value="SUBMIT YOUR ANSWER"> </div> </form> </body> </html> IF THEY ANSWER CORRECTLY I WANT TO INCREASE A SCORE COUNTER IN A COOKIE AND PRINT THE RESULTS ON THE LAST PAGE. I assume that I have toset the cookie at the start of page 2? Here is page 2. I reall appreciate your help but I am just starting with cookies! <%@LANGUAGE="JAVASCRIPT" CODEPAGE="65001"%> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <html> <head><title>The Quiz</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css"> <!-- body { background-color: #000; } body,td,th { color: #FFF; } --> </style></head> <body> <a href='' onMouseOver='window.alert("The correct answer is not Mars, good luck")'>Would you like a 50/50?</a> <div align="center"> echo "Your answer is ", $_REQUEST['ANSWER']; if ($_REQUEST['ANSWER'] == "PHP") { echo ("<br>Correct, Well done</br>"); } else { echo ("<br>Incorrect</br>"); } ?> </div> <form action="http://www.0000000ac.uk/~08007934/php/quiz3.php" method="get"> <p align="center">The next question...</p> <p align="center"><strong>Question Two. Which is the following is a group of interrelated web development techniques used for creating interactive web applications or rich Internet applications: </strong></p> <div align="center">Michael Jackson <input type="radio" name="ANSWER" value="Michael Jackson" > <br> Flash <input type="radio" name="ANSWER" value="Flash" > <br> AJAX <input type="radio" name="ANSWER" value="AJAX" > <br> Mars <input type="radio" name="ANSWER" value="Mars" > <br> <input type="submit" value="SUBMIT YOUR ANSWER"> </div> </form> </form> </body> </html> I am so so confused. Before I set the cooke surely I need to set a score variable e.g. $score If the user answers the first question correctly then $score = $score +1 if ($answer=="php") { ($score = $score +1) } else { $score =$score } Then I need to pass the new score value into the next page for it to be added to if the user answers correctly? THANK YOU SO MUCH, please keep helping me
  11. ok thank you. But how to get the cookie to first of all add 1 to the score if it is the correct answer and then if the user answers correctly again add 1 again? I am really confused as to how to set this up...please help
  12. Hello everyone, thank for your time. I am creating a php quiz. The first page has question 1 on it with 4 answers as radio buttons. On answering the user is directed to the second page (quiz2.php) where their answer is printed and the second question is given (this carries on until the user has answered all 5 questions). I want to create a cookie that keeps track of their correct answers and I also want to print their score out on the final page. I am totally new to cookies with php...all help welcome! Thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.