Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • My Quiz Application in PHP for WordPress Site Doesn't Return Any Results?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 409
    Answer it

    I am working in a program which is a quiz written in php for wordpress site. However it doesn't return any results after submit button is pressed, it goes to home page of website.

     

    Can you help me execute it correctly? 

     

    if (isset($_POST['answers']) && !empty($_POST['answers'])){

            $Answers = $_POST['answers']; // Get submitted answers.;

            if ($Answers == 'NULL'){

                    echo "please select all the answers";

            }

            // Now this is fun, automated question checking! ;)

            else

            {

            foreach ($Questions as $QuestionNo => $Value){

                // Echo the question

                if (!isset($Answers[$QuestionNo])) {

                    echo "answer all questions";

                    break;

                    }

                else if ($Answers[$QuestionNo] == 'A'){

    ... there is more code but it's irrelevant to this question.

    The form is:

    <form action="<?=$_SERVER['PHP_SELF']; ?>" method="post">

            <?php foreach ($Questions as $QuestionNo => $Value){ ?>

     

                <h3><?php echo $Value['Question']; ?></h3>

                <?php

                    foreach ($Value['Answers'] as $Letter => $Answer){

                    $Label = 'question-'.$QuestionNo.'-answers-'.$Letter;

                ?>

                <div>

                    <input type="radio" name="answers[<?php echo $QuestionNo; ?>]" id="<?php echo $Label; ?>" value="<?php echo $Answer; ?>" />

                    <label for="<?php echo $Label; ?>"><?php echo $Letter; ?>) <?php echo $Answer; ?> </label>

             </div>

                <?php } ?>

     

            <?php } ?>

                    <br />

                    <div>

       <input style="font-size:25px;color:white;background-color:orange;border:2px solid #336600;padding:3px;" type="submit" value="Submit Quiz"/>

     

            </div>

            </form>

        <?php

     

    This code runs perfectly fine on local php server but when i add the code shortcode to wordpress, i can see the quiz, answer but after submit, there is no result posted

    Log in

    to use Ginger

    Limited mode

    <? PHP foreach ($Questions as $QuestionNo => $Value) {?

    ×

 0 Answer(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: