我正在使用CodeIgniter 3.1.3构建一个博客,我在管理员中有一个功能来添加新用户.当我尝试添加新用户时,我收到以下错误:
The Password field does not match the confirm_password field.
虽然密码和confrom密码字段中的给定密码是相同的.
我无法弄清楚导致问题的原因.
这是我的模型:
public function insert($data){
$this->db->insert('users', $data);
return true;
}
这是我的控制器
public function add(){
//Validation Rules
$this->form_validation->set_rules('first_name','First Name','trim|required');
$this->form_validation->set_rules('last_name','Last Name','trim|required');
$this->form_validation->set_rules('email','Email','trim|required|valid_email');
$this->form_validation->set_rules('username','Username','trim|required|min_length[3]');
$this->form_validation->set_rules('password', 'Password', 'required|matches[confirm_password]');
$data['groups'] = $this->User_model->get_groups();
if($this->form_validation->run() == FALSE){
//Views
$data['main_content'] = 'admin/users/add';
$this->load->view('admin/layouts/main', $data);
} else {
//Create Data Array
$data = array(
'first_name' => $this->input->post('first_name'),
'last_name' => $this->input->post('last_name'),
'username' => $this->input->post('username'),
'password' => md5($this->input->post('password')),
'group_id' => $this->input->post('group'),
'email' => $this->input->post('email')
);
//Table Insert
$this->User_model->insert($data);
//Create Message
$this->session->set_flashdata('user_saved', 'User has been saved');
//Redirect to pages
redirect('admin/users');
}
这是我的观点:
First Name
Last Name
Email Address
Username
Password
Confirm Password
User Group
<?php echo $group->name; ?>