开发者

How to validate a single checkbox using PHP & MySQL

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

Here is the HTML.

<input type="checkbox" n开发者_Python百科ame="privacy_policy" id="privacy_policy" value="yes" />


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


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜