Jump to content

submit button won't go away


hikingwithu2

Recommended Posts

I have a form that is a quiz, the submit button reloads the page with the answers (using php_self). On the answer page the submit button is still there, and still resubmits the data if pressed. What am I missing that will make it not appear on the results page?

 

You can see the quiz here - http://www.wiegand.org/ask_questions.php - just scroll to the bottom of the page to the link.

Edited by hikingwithu2
Link to comment
Share on other sites

So how is the submit button supposed to be hidden? You have written Php conditional code to do that? You would need to post the Php code. It is not visible to a browser.

 

Your quiz gives some wrong answers so I doubt that whoever wrote the quiz is a native English speaker.

Link to comment
Share on other sites

My form opens with this statement, pretty standard -

<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">

and the submit button also -

print "<tr><td><input type='submit' name='submit' value='check answers' /></td></tr><table>";

On the results page there is still the submit button.

 

On another quiz I have there is no submit button on the results page (http://www.wiegand.org/DoDontDoesDoesntDidDidnt.php). this is the closing code for that other quiz -

// *** check the answers *** //       foreach ($_POST as $value){    if (isset ($value)){    $done++;    }    }    if ($done !=7) //set this to 1 higher than the number of questions and answers    print "<input type='submit' name='submit' value='check answers' />";    if (($done > 0)&&($done < 7)) //set this to 1 higher than the number of questions and answers    print "<p>You haven't answered all the questions. Please finish the quiz and re-submit your answers.</p>";    if($done==7){ //set this to 1 higher than the number of questions and answers    print "<p>Your score is $correct/6 correct.</p>"; //set this to the same number of questions and answers    if ($correct<'5') { //set this to the number of minimum correct answers    print "<p>You should review the information and try the quiz again.</p>"; }    if ($correct==0)    $correct='0';    else {    print "<p>The correct answers:</p>";    print "<p>$a7</p>";    print "<p>$a8</p>";    print "<p>$a9</p>";       print "<p>$a10</p>";    print "<p>$a11</p>";    print "<p>$a12</p>";    }}    print "</form></div></body></html>";

The two quizes are different so they require different code - one gets the answers checked and scored and the other doesn't.

 

On another note: maybe you can reply in a PM - what do you think is wrong with the language on the first quiz above?

Link to comment
Share on other sites

I got it working as expected. I took the code from the 'other' quiz, pasted it into the problem quiz, commented out almost everything, and now it works, that is, when the results page is loaded there is no submit button -

// *** check the answers *** //       foreach ($_POST as $value){    if (isset ($value)){    $done++;    }    }    if ($done !=7) //set this to 1 higher than the number of questions and answers    print "<input type='submit' name='submit' value='check answers' />";    //if (($done > 0)&&($done < 7)) //set this to 1 higher than the number of questions and answers    //print "<p>You haven't answered all the questions. Please finish the quiz and re-submit your answers.</p>";    //if($done==7){ //set this to 1 higher than the number of questions and answers    //print "<p>Your score is $correct/6 correct.</p>"; //set this to the same number of questions and answers    //if ($correct<'5') { //set this to the number of minimum correct answers    //print "<p>You should review the information and try the quiz again.</p>"; }    //if ($correct==0)    //$correct='0';    //else {    //print "<p>The correct answers:</p>";    //print "<p>$a7</p>";    //print "<p>$a8</p>";    //print "<p>$a9</p>";       //print "<p>$a10</p>";    //print "<p>$a11</p>";    //print "<p>$a12</p>";    //}}    print "</form></div></body></html>";    ?>

So now I will just add in a 'close window' button for those who can't seem to find the little 'x' in the corner.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...