ok trying to start pset7, need help understanding login.php
here is the part I want to undertand
if (count($rows) == 1)
{
// first (and only) row
$row = $rows[0];
// compare hash of user's input against hash that's in database
if (password_verify($_POST["password"], $row["hash"]))
{
// remember that user's now logged in by storing user's ID in session
$_SESSION["id"] = $row["id"];
// redirect to portfolio
redirect("/");
}
}
Just wanna know does this
if(count($rows) == 1
mean the query returns true or false? I mean if it returned something (a user name exsist) than 1 otherwise 0?why are we initializing
$row = $row[0]
? what if there were two same usernames? We wont be able to check the second one.... and if there were only one such username than still why the need to initialize it to 0? or did I understood something wrong?How would this
redirect("/");
redirect to portfolio?