Using CheckBox with PHP

 

  Using CheckBox with PHP

Hello. In our previous php lesson, we touched on the radio button. In this lesson, we will take a look at the checkbox usage. In our example, let's have a checkbox and a button. Let's check whether the conditions for registration on the site are accepted with Checkbox.
  <form action="Checkbox.php" method="get">
 <p>

<input type="checkbox" name="check"/>
 </p>
 <p>I have read and accept the terms <input type="submit" value="Save"/>
 </p>
</form>
 
We have one checkbox and one button. When the button (submit) is clicked, Checkbox.php (action event) codes will be activated.
The $_GET routine will be used (we'll look into it in our next tutorials)
Now let's look at the Checkbox.php codes that will be called when the button is pressed:
 if(isset($_GET['confirm']))
{
echo 'Your registration was successful';
 }
else
{
echo "

you must confirm that you accept the terms

";

}

?>