SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    HI silver trophy Silverado4x4's Avatar
    Join Date
    Jan 2001
    Location
    USA
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I know not a single drop of PHP, but I want to make a very simple PHP script.

    I am making a quiz, and the first question, they type in the answer, press submit, and it brings them to a page with their answer, the correct one, and the next question. There are a total of 4 questions. On the last question, when you submit it, I want it to tell you the how to score it (since there will be more than 1 possible way to write it out). It's one of those joke-type quizes.

    Please tell me the simplest way to make it. It should have a .php extension and not a .php3, because for some reason, it .php3 won't work.

    Thanks in advance!

  2. #2
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How do your score them? I mean it's pretty complicated since the way people word the answer is differently, which is related to linguistic

    If you don't know programming in PHP, I suggest you use pre-made scripts. I remember there are some quiz script at hotscripts.com, you might try those.
    As for php3 and php, it's just PHP! Won't make a big problem here.
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  3. #3
    HI silver trophy Silverado4x4's Avatar
    Join Date
    Jan 2001
    Location
    USA
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    They are going to score themselves.

    It will be like:

    If you got 4 out of 4 right, then you are a...

    I just need to know how to make a form that will post what you wrote on the "thank you" page and will let you submit another form, until you go through 4.

    All the ones at hotscripts don't do what I need because it is really simple. I've seen tutorials how to do it, but I can't remember where!

  4. #4
    HI silver trophy Silverado4x4's Avatar
    Join Date
    Jan 2001
    Location
    USA
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anyone?

  5. #5
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Something like this:

    PHP Code:
    <?php

      $questions
    [] = "The first question.";
      
    $questions[] = "The second question.";
      ...

      
    $answer[] = "The first correct answer.";
      
    $answer[] = "The second correct answer.";
      ...

      if (
    $question >= count($questions)):
        
    // The user has answered all four questions
    ?>

    <!-- HTML for the ending page here -->

    <?php
      
    else:

        if (
    intval($question) > 0) {
          
    // The user has already answered a question
          // Display the previous question's answer
          
    echo("<P>The last question was: $questions[$question-1]");
          echo(
    "<P>Your answer was: $answer");
          echo(
    "<P>The correct answer was: $answers[$question-1]");
        }

        
    // Display the next question
        
    echo("<P>QUESTION #".($question+1).": ".$questions[$question]);
        
    ?>
        <form action="<?=$PHP_SELF?>" method=post>
        <p>Your answer: <input type=text name=answer>
        <input type=hidden name=question value="<?=$question+1?>">
        <input type=submit>
        </form>
        <?php
      
    endif;
    ?>
    Last edited by Kevin Yank; Feb 20, 2001 at 11:21.
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  6. #6
    HI silver trophy Silverado4x4's Avatar
    Join Date
    Jan 2001
    Location
    USA
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay, thanks for that, but I had found the answer, and hadn't posted that I had yet.

    Sorry. This was the code I was looking for:

    <form action="proquiz1.php" method="post">

    HTML:
    Code:
    <B>Question #1:<BR>
    <textarea name="answer1" cols="45" rows="8"></textarea></P>
    
    <input type="submit" name="Submit" value="Submit">
    PHP:
    [code]
    <?php

    echo ("<B><I><center>$answer1<br><br><center>Explanation...");

    ?>

    Sorry I made it sound more complicated...I should of just asked how to pass a variable through a form...but oh well, I still found my answer

    Thanks anyways,
    Alan


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •