我有一个代码点火器中的用户面板。其中用户可以选择注册。我想在我的数据库中散列用户的密码。我已经用普通密码进行了注册,但我现在想对密码进行哈希处理我在类似的问题上得到了帮助,但导致了一个错误
控制器
public function signupvalidation()
{
$this->load->library('form_validation');
if($this->form_validation->run('userregister'))
{
$post = $this->input->post();
$this->load->model('userregister');
if($this->userregister->register1($post))
{
echo "insert succesfully";
}
else
{
echo "not succesfully";
}
$this->session->set_flashdata('insertsuccess','User Registration Successfully');
return redirect('user/signup');
}
else
{
$this->load->view('user/usersignup');
}
}
型号
private function hash_password($password){
return password_hash($password, PASSWORD_BCRYPT);
}
public function register1($name,$email,$password){
$data = array(
'name' => $name,
'email' => $email,
'password' => $this->hash_password($password)
);
return $this->db->insert('user', $data);
}
我得到的错误
An uncaught Exception was encountered
Type: ArgumentCountError
Message: Too few arguments to function userregister::register1(), 1 passed in C:xampphtdocsblogapplicationcontrollersuser.php on line 84 and exactly 3 expected
Filename: C:xampphtdocsblogapplicationmodelsuserregister.php
Line Number: 14
Backtrace:
File: C:xampphtdocsblogapplicationcontrollersuser.php
Line: 84
Function: register1
File: C:xampphtdocsblogindex.php
Line: 315
Function: require_once
请帮助如何操作
错误消息明确指出,您的模型方法需要三个参数,而您只提供了一个。
在您的控制器中
if($this->userregister->register1($post))
将其更改为
if($this->userregister->register1($post['name'], $post['email'], $post['password']))
我假设$post是$_post的数组。