Jump to content

CheckBox question with php


houssam_ballout

Recommended Posts

Hello all,I am building an application (web),and I am designing a form,using HTML, I'd checkboxes , I am using isset to enter the data into the database, how can I know if the user has checked or not the checkbox (using checked property), how would I enter that into database?>I am using the type of that field as binary?is that correctThanks in advance

Link to comment
Share on other sites

If the field can either be a 1 or 0, binary would probably work, I typically use tinyint.

if (isset($_POST['checkbox_name']))  $checkbox_value = 1;else  $checkbox_value = 0;//or$checkbox_value = (isset($_POST['checkbox_name']) ? 1 : 0);

Link to comment
Share on other sites

I always use tinyint, it works fine. You can also reduce the field size from the default 4 down to 1 to conserve a little space.

Also, in the html how could I enter that fact into the database?
I don't know what you mean by that.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...