我在Codeigniter中创建了一个插入表单,我已经链接了控制器和模型,我还将它们都链接到表单应该插入数据的数据库中。
但是,当我尝试输入信息并提交时,我的数据库中没有输入任何信息。
控制器:
public function insertjob()
{
$this->load->helper('form');
$data['title']="Add a new job";
$this->load->view("insertjob", $data);
}
public function addingjob()
{
$jobtype=$this->input->post('jobtype');
$jobinfo=$this->input->post('jobinfo');
$this->load->model("cmodel");
if($this->cmodel->addjob($jobtype, $jobinfo)){
$data['msg']="New job addition successful";
} else {
$data['msg']="There was an error please try again";
}
$this->load->view("confirmation",$data);
}
型号:
function details(){
$query = $this->db->select('*')->from('clientjobs')->get();
return $query->result();
}
function addjob($jobtype,$jobinfo)
{
$newjob=array("jobtype"=>$jobtype,"jobinfo"=>$jobinfo);
return $this->db->insert('clientjobs', $newjob);
}