Php program to take checkbox and radiio button values

Php program to take checkbox and radiio button values

<form action="index.php" method="post">

  Why don't they play poker in the jungle?<br>
  <input type="radio" name="jungle" value="treefrog"> Too many tree frogs.<br>
  <input type="radio" name="jungle" value="cheetah"> Too many cheetahs.<br>
  <input type="radio" name="jungle" value="river"> Too many rivers.<br><br>

  Check the box if you want your answer to be graded:
  <input type="checkbox" name="grade" value="yes"><br><br>

  <input type="submit" name="submit" value="Submit"><br>

</form>
<?php
  if (isset($_POST['submit'])) {
    if (!empty($_POST['grade'])) {
      if (!empty($_POST['jungle'])) {
        if ($_POST['jungle']=="cheetah") { echo "You got the right answer!"; }
        else { echo "Sorry, wrong answer."; }
      } else { echo "You did not choose an answer."; }
    } else { echo "Your answer will not be graded."; }
  } else { echo "Please submit the form."; }
?>
I Am Not The Owner Of These Code .I Merely Have Copied Them From Various Sources. The Only Thing I Did Is That I Am Going To Present Them In More Easy Way To Understand.

Comments

Popular posts from this blog

LED Blinking using 8051 Microcontroller and Keil C – AT89C51

Android Camera Example 2

Java Script to make text change text color