Associate
- Joined
- 11 Oct 2008
- Posts
- 268
Hello everyone. Please could some shed some light onto why I am getting this undefined variable error. Thanks for any tips 
I have cobbled together a login script using the new php hashing and verify functions.
I am getting this error:
Line 207 is the following:
And here is the full code:

I have cobbled together a login script using the new php hashing and verify functions.
I am getting this error:
PHP:
Undefined variable: db_password in C:\wamp\www\login\index.php on line 207
Line 207 is the following:
PHP:
if(password_verify($password, $db_password)) {
And here is the full code:
PHP:
$username = '';
if(isset($_POST['username']))
$username = htmlentities($_POST['username']);
$password = '';
if(isset($_POST['password']))
$password = $_POST['password'];
$sql = "SELECT * FROM login WHERE username=?";
$get = $connect->prepare($sql);
$get->execute(array($username));
if($get->rowCount() === 1)
{
$row = $get->fetch(PDO::FETCH_ASSOC); // Fetch the result
$db_username = $row['username'];
$db_password = $row['password'];
}
if(password_verify($password, $db_password)) {
` $_SESSION['username'] = $db_username;
$sql = "UPDATE login SET last_login=?, ip=? WHERE username=?";
$statement = $connect->prepare($sql);
$statement->execute(array($dt,$ip,$username));
}