I am very new to PHP and I'm trying to make a Log-In system with MySQL. I have a form where the user registers and it saves in a database table called registers. I already have the Log-In verify and all those things. When only one user is registered, it works perfectly. But when another user registers, the SELECT thing only selects the first ro (first user's pw), so the second user can't log-in because the SELECT doesn't include all the table's rows. Here is my code:
include 'cn.php';
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$user = htmlspecialchars($_REQUEST["user"]);
$u_password = htmlspecialchars($_REQUEST["password"]);
$qry = "SELECT user, password FROM registers";
$result = mysqli_query($conexion, $qry);
$row = mysqli_fetch_array($result);
$db_user = $row["user"];
$db_password = password_verify($u_password, $row["password"]);
if($u_password == $db_password) {
echo "<script>alert('You are in')</script>";
} else {
echo "<script>alert('Error')</script>";
}
}
My question is: How can I select ALL the rows inside registers, since select only detects the first row, that in this case is the first user registered?