For some reason the login only works for the last user in the database. I have a while loop, but I think it makes the program to go to the last user. I tried using if statement but then only the first user can log in.
if (username!=null && password!=null) {
pagename = "main";
} else {
username = request.getParameter("username");
password = request.getParameter("password");
while(results.next())
{
if(results.getString(2).equals(password) && results.getString(1).equals(username))
{
pagename="main";
}
else
{
pagename="start";
}
}
}
How is this caused and how can I solve it?