lundi 24 juillet 2017

Multi-Step-Form with PHP

I have a problem with a PHP script. A multi-step query is to be created, but the entire query is on one page. An important aspect of the query is a branch with an if / else condition. Unfortunately exactly this branch does not work with me. The else condition is always output. Can someone give me a tip? Where is my mistake?

Thanks in advance and best regards

Florian

<form id="QuoteForm" name="QuoteForm" data-toggle="validator" class="QuoteForm"  enctype="multipart/form-data">
        <div class="section-wrap">
        <div id="section-1" class="section">
        <fieldset>
        <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.</p>
        <div class="form-group validreqsevice">
            <form class="form-control" name="question" id="lorem" required data-error="Please make a choice.">
                Answer 1 <input type="radio" name="ans" value="ans1"/><br />
                Answer 2 <input type="radio" name="ans" value="ans2"/><br />
                Answer 3 <input type="radio" name="ans" value="ans3"/><br />
                Answer 4 <input type="radio" name="ans" value="ans4"/><br />
            </form>
            <div class="input-group-icon"></div>
            <div class="help-block with-errors"></div>
        </div>
        <div class="form-group.quoteForm-step-1">
            <button class="btn btn-custom pull-right" onclick="nextStep2()" type="button">Continue</button> 
        </div>
        </fieldset>
        </div>
        </div><!-- end section -->

        <div id="section-2" class="section slide-right">
            <?php 
                $answer = $_POST['ans'];  
                    if ($answer == "ans1")
                    {          
                        echo 'Correct';      
                    }
                    else
                    {
                        echo 'Incorrect';
                    }          
                ?>
        </div>
        <div class="form-group.quoteForm-step-2">
        <button class="btn btn-custom" type="button" onclick="previousStep1()"><span class="fa fa-arrow-left"></span> Back</button> 
        <button class="btn btn-custom pull-right" type="button" onclick="nextStep3()">Next <span class="fa fa-arrow-right"></span></button> 
        </div>
        </fieldset>
        </div>
        </div><!-- end section -->

        (More Code...)

Aucun commentaire:

Enregistrer un commentaire