I'm trying to build a login page for my forums using Apache and MySQL XAMPP Databases, But it returns the echo string multiple times, I know it goes through all of the rows in the database checking if it's true or not it returns it as "Invalid Username or Password!" until it Finds the correct login information then returns "Welcome" Might be.
while($rows = mysql_fetch_row($result)) {
//echo $rows;
if($name==$rows[1]) {
if($pass==$rows[2]) {
echo "Welcome!";
}
}
else if ($name!==$rows[1]) {
echo "Invalid Username or Password!";
if($pass!==$rows[2]) {
echo "Invalid Username or Password!";
}
}
$row = $row + 1;
}
Here is my Output:
Invalid Username or Password!Invalid Username or Password!Invalid Username or Password!Invalid Username or Password!Welcome!
How is it done so it returns just the one that is incorrect and correct strings?.