Jump to content


This topic is now archived and is closed to further replies.


How to make a form go away...

Recommended Posts

I have a quiz that has 10 questions. When the user fills out all of the radio buttons, an evaluation will come up along with the correct answers. my problem is every time someone completes a quiz, under the evaluation the quiz is still visible here is my code [code]

$questions = array($_POST["Q_1"], $_POST["Q_2"], $_POST["Q_3"], $_POST["Q_4"], $_POST["Q_5"], $_POST["Q_6"], $_POST["Q_7"], $_POST["Q_8"], $_POST["Q_9"], $_POST["Q_10"],);

if (!isset($_POST['submit'])) { // if page is not submitted to itself echo the form
} else {
$i = 0;
$throw = false;
while ($i < 10){
if ($questions[$i] == null) {
$throw = true;



if ($throw){
$error = "Please answer all of the  questions.";

} else {
$score = $Q_1 + $Q_2 + $Q_3 + $Q_4 + $Q_5 + $Q_6 + $Q_7 + $Q_8 + $Q_9 + $Q_10;
$complete = "<span class='h5'>Your score is ".$score.".</span><br />";
$description = "<span class='h2'>EXPLANATION</span><br /><br />...
then above the form I have this...

<font color="red"><? print ($error); ?></font><br />
  <? print ($complete); ?><br />
  <? print ($description); ?>

<!-- start of form --> 
                      <form method="post" action="<? $PHP_SELF ?>">
                        <span class="h2">1. True leaders are born, not made.</span><span class="body"><br>
                          <input value="0" name="Q_1" type="radio">
                          <input value="1" name="Q_1" type="radio">...

Share this post

Link to post
Share on other sites
You can put things inside a div and then mark the div as hidden, using javascript.  I can't give details as my memory is hazy, but that approach will certainly work.

Or in PHP, you can put <? if (!isset($_POST['submit'])) { ?> <form> ... </form> <? } ?>

That will only display the form if $_POST['submit'] is not set.

I hope one of those approaches helps!

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.