php - 在 php 中发布复选框值

标签 php codeigniter

我想发布复选框值并存储它,但我的发布值显示为打开。

查看

<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/

相关文章:

php - 连接注入(inject)故障排除

php - 我的插件没有正确更新(upgrader_process_complete 问题)

PHP 时区名称到偏移量

php - 如何删除 URL codeigniter 中的特殊字符

mysql - Codeigniter数据表多行选择不同价格的同一商品

php - 有 "MD5-based block cipher"的 Go 版本吗?

php - 从PHP表单提交选中的选项

.htaccess - codeigniter 网站上的图像无法读取?

php - 动态表单——设置数据库的正确方法?

codeigniter - 在 CodeIgniter 中管理虚拟主机