How to read if a checkbox is checked in PHP?

Spread the love

Sometimes, we want to read if a checkbox is checked in PHP.

In this article, we’ll look at how to read if a checkbox is checked in PHP.

How to read if a checkbox is checked in PHP?

To read if a checkbox is checked in PHP, we can check the $_POST variable.

For instance, we write

<input type="checkbox" name="test" value="value1">

to add an input.

Then we use

isset($_POST["test"])

to check if the checkbox with name test is checked when we make a post request with isset.

Conclusion

To read if a checkbox is checked in PHP, we can check the $_POST variable.

Leave a Reply

Your email address will not be published.