php - Password submitted in form does not match password at the database -
i wrote login form, , after hitting submit button, want check if user exists @ database.
if(isset($_post['submitbtn'])){ if($_post['senderlogin'] == 'customer'){ $checkifexists = new customersdao(); $stam = $checkifexists->isexist($_post["name"], $_post["password"]); var_dump($stam); } }
and checking that:
public function isexist($name, $password) { $this->connect(); if($this->con){ $sql = "select * customers name=? , password=?"; $stmt = $this->db->prepare($sql); $password = md5($password); $stmt->bindparam(1, $name); $stmt->bindparam(2, $password); $stmt->execute(); $fetched = $stmt->fetchcolumn(); $this->disconnect(); if($fetched > 0) { return true; } else { return false;} } }
the passwords @ database encrypted md5.
i tried type user exists @ customers table, , didn't work.
i tried match names , worked, problem comparison of password submitted passwords @ database.
there seems nothing wrong code, and...
"i tried match names , worked, problem comparison of password submitted passwords @ database."
when using hash functions passwords or sensitive data, developers append "salt" strings prevent easy break of these hashs. see in code use md5()
on password without kind of salt. , maybe on other point of script, in function adds user database example, hashing password salt , hash won't match.
Comments
Post a Comment