JSP Login PAge
Hello every1,
Im trying to create a login page, but all im getting is login Unsuccessful, can you please have a look at the code bellow and Help me please.
Thank you.
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<%
Connection con = null;
Statement stat = null;
ResultSet rs = null;
String CusID = request.getParameter("customerid"); // htm form param > store in - email
String Pass = request.getParameter("password");
String rURL = "...";
if (Pass.length() == 0){response.sendRedirect(rURL); }
try
{
Class.forName("org.gjt.mm.mysql.Driver");
con = DriverManager.getConnection("...");
stat = con.createStatement();
rs = stat.executeQuery("select * from customers WHERE customerid='"+CusID+"'");
boolean found = false;
String customerid = "";
String password = "";
while (rs.next())
{
customerid = rs.getString("customerid");
password = rs.getString("password");
if (customerid.equals(CusID) && password.equals(Pass)) {
found = true;
}
} // end while
if (found == true){
out.println("<h2>Login Successful</h2>");
out.println("Welcome back <b>" + customerid + "</b>!
");
}// ~if
if (found == false) {
out.println("<h2>Login Unsuccessful</h2>");
}// ~if
rs.close();
}// end try
catch (Exception e) {
%>
<%=e.getMessage()%>
<%}
%>

