我是新来的codeigniter,我已经尝试了一切,但我的表单仍然没有提交到数据库。CodeIgniter 3:表单不提交
这是我的代码。我严重无法找到我出错的地方了。
VIEW
<?= form_open('forms/submit_shifter_form');?>
<div id="form-interview-fill-mainform" class="form-group">
<div class="container">
<div class="col-sm-12">
<div class="input-group">
<label>Reason/s for shifting:</label>
<input type="text" class="form-control form-input" name="shifter_reason">
</div>
<div class="col-sm-6">
<div class="input-group">
<label>Strengths:</label>
<input type="text" class="form-control form-input" name="shifter_strength">
</div>
</div>
<div class="col-sm-6">
<div class="input-group">
<label>Weaknesses:</label>
<input type="text" class="form-control form-input" name="shifter_weakness">
</div>
</div>
</div>
</div>
<?php echo form_submit('submit','Confirm', 'class="btn btn-success btn-lg" id="submit"');?>
<?php echo form_close();?>
控制器
<?php
defined('BASEPATH') or exit('No direct script access allowed ');
class Forms extends CI_Controller {
public function session(){
if($this->session->userdata('logged_in')){
$session_data = $this->session->userdata('logged_in');
$data['id'] = $session_data['id'];
$data['username'] = $session_data['username'];
$data['password'] = $session_data['password'];
return $data;
}
}
public function submit_shifter_form(){
$shifter = array(
'course' => $this->input->post('shifter_course'),
'reason' => $this->input->post('shifter_reason'),
'strength' => $this->input->post('shifter_strength'),
'weakness' => $this->input->post('shifter_weakness'),
'futureContribution' => $this->input->post('shifter_contribution')
);
$session_data = $this->session->userdata('logged_in');
$id = $session_data['id'];
$this->load->model('forms_model');
$this->forms_model->shifter_form_submit($id,$shifter);
redirect(site_url('profile'), 'refresh');
}
}
模型
<?php
defined('BASEPATH') or exit('No direct script access allowed ');
class Forms_Model extends CI_Model{
function shifter_form_submit($id,$shifter)
{
$this->db->insert('tbl_prototype_shifter',$shifter);
$insert_id = $this->db->insert_id();
$shift = array(
'studentId' => $id
);
$this->db->where('id', $insert_id);
$this->db->update('tbl_prototype_shifter', $shift);
}
}
我的其他形式提交适当的在我的数据库中的数据,之后我加入这个新的形式,我看起来像它不再正确提交。请,能有人帮助,我想不通我哪里错了
您的提交按钮在哪里? –
我刚刚编辑它,对不起 –
你确定'<?='打印表单标签吗? –