mysql - php login password not accepted -


i not able log in using below code. so, here's code:

    public function auth($login, $password)     {         $login = $this->db->real_escape_string($login);         $tmp = $this->db->query("select id, password users login = '$login'");          if (!$tmp->num_rows) {             return false;         }          $userdata = $tmp->fetch_assoc();         var_dump($userdata); var_dump(sha1($password.'|'.$login));          if ($userdata[‘password’] == sha1($password.'|'.$login)) {              return $userdata['id'];          } else {             return false;         }      } } 

and here's output var dumps

array(2) { ["id"]=> string(1) "7" ["password"]=> string(40) "e1c6d95317081ebddaea4cd1a061415c39dafb2b" }  string(40) "e1c6d95317081ebddaea4cd1a061415c39dafb2b" 

how can modify it, can log in?

why dont do..

$this->db->query('select `id`, `password` `users` `login` = ? , `password` = sha1(concat(?,"|",?))',array($login,$password,$login)); 

Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -