Passing checkbox state to PHP

前端 未结 6 1672
南笙
南笙 2021-01-24 22:54


This works fine, ho

6条回答
  •  清歌不尽
    2021-01-24 23:36

    You shouldn't need the hidden field. You should in fact not trust any of the form fields sent in the first place. What this means is that you cannot make code which takes the sent fields and trust them to send the correct data (which I assume you do now).

    What you should do is to handle all fields you expect to get. That way if you don't get the checkbox value you can still handle that as if it was unticked. Then you also get the added inherent feature of throwing away form data you don't expect in the first place.

提交回复
热议问题