mercredi 14 juillet 2021

POST value of checkbox sent with basic HTML form always returns 'on'

I need to implement a very basic honeypot hidden checkbox server side validation. This is my HTML form:

<form method="POST" action="handle-form.php">
    <input type="checkbox" id="validate_box" name="validate_box" style="display:none !important" tabindex="-1" autocomplete="off">
</form>

When I try to print out the $_POST['validate_box'] in my handle-form.php, it always returns 'on'. Same goes for isset($_POST['validate_box']), always returns true. It doesn't matter if the checkbox is checked or not.

I've also tried adding a custom default value to the checkbox and compare it in PHP, but same result.

What is the issue here?




Aucun commentaire:

Enregistrer un commentaire