How to validate a single checkbox using PHP & MySQL

后端 未结 2 1253
迷失自我
迷失自我 2020-12-21 11:21

I was wondering how can I validate a single checkbox using PHP and MySQL.

Here is the HTML.



        
相关标签:
2条回答
  • 2020-12-21 11:49

    If isset($_REQUEST['privacy_policy']) returns true, they ticked the box. If not, they didn't.

    0 讨论(0)
  • 2020-12-21 12:10

    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

    • users may not have javascript turned on
    • you can't trust anything from the client side anyway :)

    If you're using jQuery for anything else, the jQuery Validation plugin makes client side validation very straightforward.

    0 讨论(0)
提交回复
热议问题