How to read if a checkbox is checked in PHP?

Thew picture Thew · Dec 29, 2010 · Viewed 810.9k times · Source

How to read if a checkbox is checked in PHP?

Answer

m_vitaly picture m_vitaly · Dec 29, 2010

If your HTML page looks like this:

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

After submitting the form you can check it with:

isset($_POST['test'])

or

if ($_POST['test'] == 'value1') ...