I want to post checkbox value and store it,but my post value is shown as on.
View
<label for="name">Programme Applied for:</label><br>
<br>
<input name="program" type="checkbox">Six Months Computerized Accounting Diploma<br>
<input name="program" type="checkbox">Six Months Computerized Accounting Diploma<br>
<input name="program" type="checkbox">Two Months Diploma in taxation (Direct)<br>
<input name="program" type="checkbox">Three Months Diploma in taxation (Direct & Indirect)<br>
<input name="program" type="checkbox">One Year Diploma in Accounting Finance Taxation <br>
<input name="program" type="checkbox">Banking and Payroll
<br><br>
<div class="clear"></div>
<div class="text-danger"><?php echo form_error('program'); ?></div>
Controller
$data=array('prg_applied' => $this->input->post('program'));
$insert = $this->firstmodel->insert_record($data);
You have to have value field, if you dont have value field then it will show "on" for checked boxes
<input name="program" type="checkbox" value='Three Months Diploma in taxation (Direct & Indirect)'>Three Months Diploma in taxation (Direct & Indirect)<br>
It looks like you want radio rather than checkbox. Then you can have multiple selectable inputs of the same name
and different value
, where the selected box will provide value in the HTTP request.
You also use <label>
wrong. It is supposed to be for individual inputs:
<label><input name="program">Six Months Computerized…</label><br>
Or:
<input name="program" id="x"> <label for="x">Six Months Computerized…</label><br>