Using an HTML checkbox to put 1 or 0 into a MySQL table

后端 未结 5 1469
离开以前
离开以前 2020-12-15 22:23

I am using a simple HTML checkbox in a form to put a 1 for checked and a 0 for unchecked in a field called \"subcheck\" in a MySQL table.

Does the checkbox default t

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-15 23:01

    To be sure that always 1 or 0 is sent, you can insert an input hidden with the same name of the checkbox in the html:

    //The input hidden
    
    
    //The checkbox
     
    

    This way, you don't need to check in server side if the textbox is set or not ;)

提交回复
热议问题