How do I see which checkbox is checked?

Karem picture Karem · Feb 15, 2010 · Viewed 156.9k times · Source

How do I check in PHP whether a checkbox is checked or not?

Answer

Tomas Markauskas picture Tomas Markauskas · Feb 15, 2010

If the checkbox is checked, then the checkbox's value will be passed. Otherwise, the field is not passed in the HTTP post.

if (isset($_POST['mycheckbox'])) {
    echo "checked!";
}