Open new page automatically in php with result from previous page

Asked

Viewed 50 times

0

Next person I have a quiz and at the end a button Submit, when clicking I do some php operations to return a result of the quiz, but returns on the same page, with all questions of the quiz, I need to return this result or on a new page, or when I hit the button the questions would disappear and only the result would be, someone who can help me? this is the php button and code I’m using to give the result...

<button type="submit" name="btnSubmit">Enviar</button>

<?php
if ($_SERVER['REQUEST_METHOD']=='POST') {
    if(isset($_POST['btnSubmit'])){

        foreach ($_POST['question'] as $key => $value) {
            $letter[$key] = array_sum($value);
        }
        echo '<div class="col-md-12">Letra com maior valor: '.array_search(max($letter),$letter).'</div>'; 
        if (array_search(max($letter),$letter) == "A" ){
            echo 'Lorem';
        }
        if (array_search(max($letter),$letter) == "B" ){
            echo 'Lorem ipsum';
        }
        if (array_search(max($letter),$letter) == "C" ){
            echo 'Lorem ipsum lorem';
        }
    }

}

?>

1 answer

0


In your search form you need to define the property "action" with the address of the destination page, ex:

<form action="/resultado.php" method="POST">
  <input type="text" name="question"...>
  <button type="submit" name="btnSubmit">Enviar</button>
</form>

source: https://www.w3schools.com/tags/att_form_target.asp

  • thanks I’ll try here ja return

Browser other questions tagged

You are not signed in. Login or sign up in order to post.