prepare('SELECT id, authentication_algorithm, authentication_salt, authentication_string FROM users WHERE name = :username;'); $result = $statement->execute(array('username' => $username)); if ($statement->rowCount() > 0) { //existing user name $dbentry = $statement->fetch(); //chechk for correct password if ($dbentry['authentication_string'] == hash($dbentry['authentication_algorithm'], $password . $dbentry['authentication_salt'])) { //password correct $_SESSION['user_id'] = $dbentry['id']; $_SESSION['user_ip'] = $_SERVER['REMOTE_ADDR']; //ip will be used to prevent session stealing header("Location: https://lostcave.ddnss.de/common/threadr/userhome/"); } else { //password inorrect header("Location: https://lostcave.ddnss.de/common/threadr/login/?error=credentials"); die(); } } else { //wrong user name header("Location: https://lostcave.ddnss.de/common/threadr/login/?error=credentials"); die(); } ?>