How to read if a checkbox is checked in PHP?

Solution for :How to read if a checkbox is checked in PHP?

If our HTML page looks like this:

1
<input type="checkbox" name="checkbox1" value="value1">

After submitting the form we can check it with:

1
isset($_POST['checkbox1'])

OR

1
2
3
4
5
if ($_POST['checkbox1'] == 'value1'){
 
//I am checked.
 
}

No comments:

Post a Comment