mercredi 22 juillet 2015

Using PHP to "check" checkbox only if it's been checked

I've got a checkbox on my PHP page, and when I post back to the page I only want to check the checkbox if the user has already checked it. I'm using the following line of code, but this ALWAYS checks the checkbox, even if the user didn't check it themselves. How can I do this?

<input type="checkbox" name="terms" id="terms" <?php if (isset($_POST['terms']) == true) echo('checked="checked"'); ?> /> I agree to the Terms as stated above.




Aucun commentaire:

Enregistrer un commentaire