got a problem with a login page, my code doesn't seem to seperate each users details from the database. Here is my code: any suggestions?
<%@page import="java.sql.*"%>
<%@page contentType="text/html"%>
<%
String loginMessage = "";
String un = "";
String pw = "";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection cn = DriverManager.getConnection("jdbc:odbc:RentalDB", "", "");
Statement st = cn.createStatement();
ResultSet r = st.executeQuery("SELECT * FROM Member");
if (request.getParameter("btnLogon") != null) {
while (r.next()) {
un += r.getString("Email");
pw += r.getString("Password");
if ((request.getParameter("txtUsername").equals(un)) && (request.getParameter("txtPassword").equals(pw))) {
session.setAttribute("Logon", "OK");
response.sendRedirect("Menu Page.jsp");
loginMessage = "well done";
} else {
loginMessage = "Login details incorrect";
session.setAttribute("Logon", "NOT_OK");
}
}
}
cn.close();
%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Login Page</title>
</head>
<body>
<form method ="post">
<center>
<p> Please Log on: <br /></p>
Username: <input name="txtUsername" type="text" /> Password: <input name="txtPassword" type="password" /> <br/>
<p><input name="btnLogon" type="submit" value="Logon" /> <br/> </p>
<p><%=loginMessage%></p>
<p><%=un%> </p>
</center>
</form>
</body>
</html>