我想在数据库名称db2中插入数据表名称table1来自注册表,但它给我以下错误,因为“列Name不能为空”,我不明白,请帮助我
我的控制器名称是Abc.php,代码是
<?php
defined('BASEPATH') OR exit ('No direct script access allowed');
class Abc extends CI_Controller {
public function index(){
$this->load->database();
$this->load->model('Done');
$this->load->view('codingregi');
$data = array(
'Name' => $this->input->post('name'),
'Email' => $this->input->post('email'),
'Password' => $this->input->post('password'),
'Gender' => $this->input->post('gender')
);
$this->Done->savingdata($data);
redirect('Abc/index');
}
}
?>
型号名称是Done.php和是
<?php
defined('BASEPATH') OR exit ('No direct script access allowed');
class Done extends CI_Model
{
public function savingdata($data)
{
//this array is used to get fetch data from the view page.
//$xyz = "insert into table1 values ('$name','$email','$password','$gender')";
//$this->db->query($xyz);
{
$this->db->insert('table1',$data);
$emp_id = $this->db->insert();
}
return emp_id;
}
}
?>
和注册表名称是 codingregi.php
<!DOCTYPE html>
<html>
<head>
<title>registraion form</title>
</head>
<body>
<form method="POST" method="Abc.php">
Name:<input type = "text" name="name"><br></br>
email: <input type = "email" name="email"><br></br>
Password: <input type ="password" name="password"><br></br>
Gender: <input type ="radio" name="gender" value="male">Male
<input type ="radio" name="gender" value="female">Female<br></br>
<input type ="submit">
</form>
</body>
以下是完整的错误描述
错误编号:1048
列“名称”不能为空
INSERT INTO table1( Name, Email, Password, Gender) 值 (NULL, NULL, NULL, NULL)
文件名:C:/xampp/htdocs/CodeIgniter-3.1.10/CodeIgniter-3.1.10/system/database/DB_driver.php
行号:691
蓝山帝景