Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function set__password($passwd) {
- self::$password = password_hash($passwd, PASSWORD_BCRYPT, array('cost' => 12));
- }
- $2y$12$lTMEP0wevDEMX0bzStzoyOEzOTIAi3Hyhd3nYjGwzbI
- $username = $_POST['username'];
- $password = $_POST['password'];
- $DB = Database::getInstance();
- // Get the stored password hash
- $res = $DB->run__query('SELECT password FROM users WHERE username = "' . $username . '"');
- $hash = $res[0]['password'];
- // Do the passwords match?
- if(password_verify($password, $hash)) {
- echo 'success';
- } else {
- echo 'failed';
- }
- if(isset($_POST['submit'])){
- include 'database.php';
- $uid = mysqli_real_escape_string($conn,$_POST['uid']);
- $pass = mysqli_real_escape_string($conn,$_POST['pass']);
- $query = "SELECT * FROM user WHERE username ='$uid'";
- $tbl = mysqli_query($conn, $query);
- if (mysqli_num_rows($tbl)>0){
- $row = mysqli_fetch_array($tbl, MYSQLI_ASSOC);
- $hash = $row['password'];
- if (password_verify($pass, $hash)){
- echo "success";
- }
- else {
- echo "log in error";
- }
- }
- }
Add Comment
Please, Sign In to add comment