It's the first time I am using PHP native password functions in my application. I stored user's password using code below:
password_hash($this->input->post('password'),PASSWORD_BCRYPT);
And result is stored in database. Now I want to verify user in login process.
My question is here. I have 2 choices:
Method 1
$sql = "SELECT id,password FROM tbl_members WHERE email = ? LIMIT 1";
$result = $this->db->query($sql,array('user@site.com'));
if ($result->num_rows()) {
$row = $result->row();
$hash = $row->password;
if (password_verify($this->input->post('password'), $hash)) echo 'Successful login';
}
Method 2
$hash = password_hash($this->input->post('password'),PASSWORD_BCRYPT);
$sql = "SELECT id FROM tbl_members WHERE email = ? AND password = ? LIMIT 1";
$result = $this->db->query($sql,array('user@site.com',$user_hashed_password));
if ($result->num_rows()) echo 'Successful Login';
Which method is more suitable for a login process?