37 users online (0 members and 37 guests)  

Thread: Help in quiz!


  Results 1 to 4 of 4

Related

  1. Trivia Quiz help    Forum: PHP Forum
    Replies: 1
  1. #1
    bertugolu's Avatar
    New User

    Status
    Offline
    Join Date
    Mar 2007
    Posts
    15

    Question Help in quiz!

    I was doing a quiz and I need help!

    PHP Code:
    <html>

    <
    body>

    <
    body bgcolor="#d1d1d1">

    <
    h1>Welcome to the quiz</h1>

    <
    h3Done by ...not important now </h3>

    <
    form>
    <
    input type="button" value="Start quiz" onclick="window.location.href='quiz1_t1.php'"
    </
    form>

    </
    body>

    </
    html
    That is the first page

    Then the acutal questions starts

    PHP Code:
    <html>
    <
    body>

    <
    body bgcolor="#d1d1d1">

    <
    form method=post action=quiz1ans_t1.php>

    Question 1What is Arachnophobia?"

    <p> <input type=radio name=que value=g> Fear of Spiders </p>
    <p> <input type=radio name=que value=b> Fear of Men </p>
    <p> <input type=radio name=que value=b> Fear of Women </p>
    <p> <input type=radio name=que value=b> Fear of dogs </p>



    <input type="
    submit" value="Submit Answers">

    </form>

    </html> 
    checks if it right or wrong, and shows score

    PHP Code:
    <html>

    <body>

    <body bgcolor="#d1d1d1">


    <?php

    $ans
    =$_POST ['que'];
    $score=0;

    If (
    $ans==g)
    $score=$score+1;

    If (
    $ans==g)
    {
    echo 
    "Yes, the answer is good! You currently have $score point";
    }
    else
    {
    echo 
    "No, the answer should have been Fear of Spiders!. You currently have $score points";
    }
    ?>

    <form method=post action=quiz2_t1.php>


    <input type="button" value="Continue quiz" onclick="window.location.href='quiz2_t1.php'">

    </body>

    </html>
    Then i want to transfer $score to the next page, so it displays the score

    PHP Code:
    <html>
    <body>

    <body bgcolor="#d1d1d1">


    <form method=post action=quiz2ans_t1.php>

    <?php

    echo "you currently have $score points";

    ?>

    Question 2: For which disease does pneumonoultramicroscopicsilicovolcanioniosis refer to?"

    <p> <input type=radio name=que value=b> Heart Disease </p>
    <p> <input type=radio name=que value=b> Liver Disease </p>
    <p> <input type=radio name=que value=g> Lung Disease </p>
    <p> <input type=radio name=que value=b> Kidney Disease </p>




    <input type="submit" value="Submit Answers">

    </form>

    </html>
    How can i aquire the $score variable

  2. #2
    HTML's Avatar
    Administrator

    Status
    Offline
    Join Date
    Aug 2000
    Posts
    3,445

    Follow HTML On Twitter Add HTML on Facebook Add HTML on Google+ Add HTML on Linkedin Visit HTML's Youtube Channel

    Re: Help in quiz!

    I am sure whoever is able to help you will want to see quiz2ans_t1.php it may be a good idea to go ahead and post it so that you are ahead of the game.

    Dave
    AHFBWEB Less customers per server, more power for you!

    Business Class Shared Hosting

  3. #3
    bertugolu's Avatar
    New User

    Status
    Offline
    Join Date
    Mar 2007
    Posts
    15

    Re: Help in quiz!

    Ok, used the include function. But the thing is that i only need one variable from the file, and it is displaying the whole file!

  4. #4
    vinyl-junkie's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    721

    Re: Help in quiz!

    You still need to post the code for quiz2ans_t1.php before we can be of much help.
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more



Tags for this Thread