What are common pitfalls when working with checkboxes in PHP forms?

One common pitfall when working with checkboxes in PHP forms is that unchecked checkboxes do not get submitted in the form data. To solve this issue, you can use hidden input fields with the same name as the checkboxes to ensure that the value is submitted, even if the checkbox is unchecked.

<form method="post" action="process_form.php">
    <input type="checkbox" name="checkbox[]" value="option1">
    <input type="hidden" name="checkbox[]" value="">
    <input type="checkbox" name="checkbox[]" value="option2">
    <input type="hidden" name="checkbox[]" value="">
    <input type="submit" value="Submit">
</form>
```

In the PHP processing script (process_form.php), you can then check for the presence of each checkbox option in the $_POST data:

```php
$checkboxes = isset($_POST['checkbox']) ? $_POST['checkbox'] : array();

if (in_array('option1', $checkboxes)) {
    // Checkbox option 1 was checked
}

if (in_array('option2', $checkboxes)) {
    // Checkbox option 2 was checked
}