我正在尝试在表中插入表单值。我不知道它不发布值的原因它给我的错误值不能为空我确信我在表单中提到了正确的表值有人能检查我犯了什么错误吗
这是我的按钮:
<td><form action="<?php echo base_url();?>Dashboard/ReviewManagement" method="POST">
<input type="hidden" name="topicid" value="<?php echo $proview->id;?>">
<input type="hidden" name="courseid" value="<?php echo $proview->courseId;?>">
<button type="submit" class="btn btn-xs btn-warning" >
<span class="icon-ok"></span>
</button>
</form></td>
这是我的控制器:
public function ReviewManagement() {
$username = $this->session->userdata('user_name');
$data['userslist'] = $this->Dashboard_model->getUsers();
$insert_data = array(
'topicid' =>$this->input->post('topicid'),
'stage' => $this->input->post('stage'),
'allocatedresource' => $this->input->post('allocatedresource'),
'status' => 1,
'createdby' => $username,
'createdon' => date('d/m/Y'),
'expec' =>$this->input->post('expec')
);
$this->Dashboard_model->reviewmanagerInsert($insert_data);
$this->load->view('template/header');
$this->load->view('dashboard/reviewmanagement',$data);
$this->load->view('template/footer');
}
Here is my model:
public function reviewmanagerInsert($data)
{
$this->db->insert('reviewmanager',$data);
}
以下是我的观点:
<form action="<?php echo base_url();?>Dashboard/ReviewManagement" method="post">
<div class="form-row">
<div class="col-md-3">Reviewer:</div>
<div class="col-md-9">
<select name="allocatedresource" class="form-control">
<option value="0">Select Reviewer</option>
<?php foreach ($userslist as $users) { ?>
<option value="<?php echo $users->id; ?>"><?php echo $users->username; ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-row">
<div class="col-md-3">Stage:</div>
<div class="col-md-9">
<select class="form-control col-md-8" name="stage" required="">
<option value="" selected="">Select Stage</option>
<option value="1">PB Review</option>
<option value="2">PB2 Review</option>
<option value="3">Alpha Review</option>
<option value="4">Beta Review</option>
<option value="5">Gamma Review</option>
</select>
</div>
</div>
<div class="form-row">
<div class="col-md-3">Due Date:</div>
<div class="col-md-9">
<div class="input-group">
<div class="input-group-addon"><span class="icon-calendar-empty"></span></div>
<input type="text" name="expec" autocomplete="off" required="" class="datepicker form-control" value=""/>
</div>
</div>
</div>
<div class="form-row">
<div class="col-md-8 col-md-offset-2">
<button type="submit" class="btn btn-primary btn-block">Assign</button>
</div>
</div>
</form>
出现以下错误:
列“topicid”不能为空
INSERT INTO `reviewmanager`
(`topicid`, `stage`, `allocatedresource`,
`status`, `createdby`, `createdon`, `expec`)
VALUES (NULL, NULL, NULL, 1, 'admin', '16/08/2018', NULL)
谁能帮我一下我犯了什么错误
提前谢谢。
3条答案
按热度按时间4sup72z81#
只需在表单中添加以下两个输入。。。
dhxwm5r42#
只使用一个带有隐藏字段的窗体,并使用jquery-like为这些隐藏字段赋值
您的按钮视图
在主窗体中,在下面添加隐藏字段
然后在下面添加js来赋值
不过,这个答案没有经过检验。
rsaldnfx3#
解决方法如下
从下面改成了第二个
控制器代码1:
控制器代码2