Php login via email in mysql -
hi guys have loging via email , , want add login via email. when add (login=:login or) in sql query, got bug can login password.
here code :
public function login($login,$upass) { try { $stmt = $this->conn->prepare("select * klient login=:login or email=:login limit 1"); $stmt->execute(array(':login' => $login)); $userrow = $stmt->fetch(pdo::fetch_assoc); if ($stmt->rowcount() == 1) { if ($userrow['userstatus'] == "y") { if ($userrow['haslo'] = $upass) { $_session['usersession'] = $userrow['idklient']; return true; } else { header("location: index.php?error"); exit; } } else { header("location: index.php?inactive"); exit; } } else { header("location: index.php?error"); exit; } } catch (pdoexception $ex) { echo $ex->getmessage(); } }
edit:
i'm trying add password_hash(), when login in website going down. tried add password hash website going down when login in.
public function login($login, $upass) { try { $stmt = $this->conn->prepare("select * klient login=:user_login or email=:user_login"); $stmt->execute(array(":user_login" => $login)); $userrow = $stmt->fetch(pdo::fetch_assoc); if ($stmt->rowcount() == 1) { if ($userrow['userstatus'] == "y") { if ( password_verify($upass, $userrow['haslo'])) { $_session['usersession'] = $userrow['idklient']; return true; } else { header("location: index.php?error"); exit; } } else { header("location: index.php?inactive"); exit; } } else { header("location: index.php?error"); exit; } } catch (pdoexception $ex) { echo $ex->getmessage(); } }
you need change here add param email
$stmt->execute(array(':login' => $login,':email' => $login));
Comments
Post a Comment