我想发布复选框值并存储它,但我的发布值显示为打开。
查看
<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);
最佳答案
您必须有值字段,如果您没有值字段,则选中的框将显示“on”
<input name="program" type="checkbox" value='Three Months Diploma in taxation (Direct & Indirect)'>Three Months Diploma in taxation (Direct & Indirect)<br>
关于php - 在 php 中发布复选框值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43557171/