$row = mysql_num_rows($result);
has the value of 1
as expected. This is because the SQL query has found 1 row with the criteria. However, $row[3]
is returning NULL
when I was expecting a hash value. Any help will be appreciated. So my question is, why is $row[3]
holding the value of null
and not the hash value expected which is on my SQL database?
<?php
include('config.php');
$email = $_POST['email'];
$password = $_POST['password'];
$query = "SELECT * FROM users WHERE email='$email';";
$result = mysql_query($query);
$row = mysql_num_rows($result);
$password_relative = $row[3];
echo "Row Value: ".$row."<br>";
var_dump($password_relative); // holding null???
var_dump($row); // holding 1 as intended
echo "Inputed Password: ".$password."<br>";
echo "Password Value On Server:".$password_relative."<br>";
if ($row > 0) {
// password_verify(password, hash);
if(password_verify($password, $password_relative)) {
// set seesion variables
echo 'Successful sign in<a class="link" href="index.php">Go to dashboard</a>';
} else {
echo 'Password is wrong!<a class="link" href="SignIn.php">Go to sign in</a>';
}
} else {
echo 'The details given show that you do not have an account with us<a class="link" href="SignIn.php">Go to sign in</a>';
}
?>