Jump to content

[SOLVED] Isset help


dink87522

Recommended Posts

What I had was the user clicking the submit button and it would be processed by another PHP file. If I wish to process it on the same page I understand that you use the isset function. However this will not work for me and with the submit button's action, what does that then become?

 

<form action="check.php" method="post">
<input type="hidden" name="country" value="<?php echo("$rnd")    ?>"/>
<input type="text" size="55" name="answer" value="" />
<input type="submit" name="submit" value="Submit" />
</form>
<?php  if (isset($_POST['submit']){
$userAnswer = $_POST['answer'];
$rnd = $_POST['country'];
$answer = $capitals[$rnd]; 
$userAnswerLower = strtolower($userAnswer);
$answerLower = strtolower($answer);
//echo("userAnswerLower: $userAnswerLower <br />");
if ($userAnswerLower == $answerLower) {
echo("<h3>CORRECT, $answer is indeed the capital of $countries[$rnd]!</h3>");
} else { 
echo("<h3>INCORRECT,  the capital of $countries[$rnd] is $capitals[$rnd]! </h3>");
}
  }
?>

Link to comment
https://forums.phpfreaks.com/topic/169398-solved-isset-help/
Share on other sites

Archived

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

×
×
  • Create New...

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.