I have user pannel in a codeigniter. where user have a option to register. i want to user's password to hashed in my database. i have done the registeration with normal password but i want now password to be hashed. I have taken help with similar questions but resulted into an error
controller
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');
}
}
model
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);
}
the error i have got
An uncaught Exception was encountered
Type: ArgumentCountError
Message: Too few arguments to function userregister::register1(), 1 passed in C:\xampp\htdocs\blog\application\controllers\user.php on line 84 and exactly 3 expected
Filename: C:\xampp\htdocs\blog\application\models\userregister.php
Line Number: 14
Backtrace:
File: C:\xampp\htdocs\blog\application\controllers\user.php
Line: 84
Function: register1
File: C:\xampp\htdocs\blog\index.php
Line: 315
Function: require_once
please help how to do it
Error message clearly state that your model method required three arguments and you supplied just one.
In your controller
if($this->userregister->register1($post))
change it to
if($this->userregister->register1($post['name'], $post['email'], $post['password']))
I am assuming that $post is an array of $_POST.
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
PHP (from the English Hypertext Preprocessor - hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites.
The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
https://www.php.net/
CodeIgniter is a framework that is known for requiring a minimum amount of customization to get it up and running. This allows those who choose it to work at a good pace. It has been updated many times since its inception in 2006. Now the most recent version is 4.0.3.
https://www.codeigniter.com/
Welcome to the Q&A site for web developers. Here you can ask a question about the problem you are facing and get answers from other experts. We have created a user-friendly interface so that you can quickly and free of charge ask a question about a web programming problem. We also invite other experts to join our community and help other members who ask questions. In addition, you can use our search for questions with a solution.
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.