I'm trying to save the checkbox value .. I'm doing a enrollment system with a checkbox form. It's function is to know if the student pass the requirement, so I assign it as a boolean type. It must save the value of '1' if the checked and '0' if unchecked.
and the error are:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '')' at line 2
and if I uncheck one of the requirement this is what happen:
Notice: Undefined index: brigada_form in C:\xampp2\htdocs\es\add_newstud.php on line 12
Notice: Undefined index: two_picture in C:\xampp2\htdocs\es\add_newstud.php on line 18
I really need some help. Here is the code..
Sample form: 1 set the value as '1' and the default value in my database is '0'
<input type="checkbox" name="two_picture" id="two_picture" value="1" />
php code add_newstud.php
$requirement_id = $_POST['requirement_id'];
$enrollment_form = $_POST['enrollment_form'];
$report_card = $_POST['report_card'];
$brigada_form = $_POST['brigada_form'];
$physical_inspection_form= $_POST['physical_inspection_form'];
$agreement_upon_enrollment = $_POST['agreement_upon_enrollment'];
$nso = $_POST['nso'];
$good_moral = $_POST['good_moral'];
$one_picture = $_POST['one_picture'];
$two_picture = $_POST['two_picture'];
$insert_req = "INSERT INTO es_req_newstud(requirement_id,enrollment_form,report_card,brigada_form,physical_inspection_form,agreement_upon_enrollment,nso,good_moral,1x1_picture,2x2_picture) `VALUES` ('$requirement_id','$enrollment_form','$report_card','$brigada_form','$physical_inspection_form','$agreement_upon_enrollment','$nso','$good_moral','$one_picture','$two_picture)";
mysql_query($insert_req) or die(mysql_error());
VALUESwrapped like that? I would suggest just:INSERT INTO es_req_newstud(requirement_id,enrollment_form,report_card,brigada_form,physical_inspection_form,agreement_upon_enrollment,nso,good_moral,1x1_picture,2x2_picture) VALUES ('$requirement_id','$enrollment_form','$report_card','$brigada_form','$physical_inspection_form','$agreement_upon_enrollment','$nso','$good_moral','$one_picture','$two_picture')