I was wondering how can I validate a single checkbox using PHP and MySQL.
Here is the HTML.
<input type="checkbox" name="privacy_policy" id="privacy_policy" value="yes" />
If isset($_REQUEST['privacy_policy']) returns true, they ticked the box. If not, they didn't.
$_REQUEST['privacy_policy'] == 'yes'Although you have asked for PHP validation, you should probably provide javascript validation on the client site as well as PHP validation. This provides a more rapid response than server side validation.
It's important to have both because
If you're using jQuery for anything else, the jQuery Validation plugin makes client side validation very straightforward.