hey,
hope somebody can help me with this, i cannot see what i'm doing wrong.
I have a html page where a user enters username and password, it is then checked at database and see's whether a user is administrator or user.If a user, user is taken to productpet shop. If its an administrator its taken to administrator screen.It is outputting the username and password but doesnt do anything else. I have all the
jsp pages created. here is my connection code etc:
Thanx
<% Connection c = null;
Statement s = null;
ResultSet rs = null;
String driver="com.mysql.jdbc.Driver";
String connectionURL="jdbc:mysql://localhost:8084/petshopwebsite";
String pw = "";
String acc = "";
%>
<html>
<head><title>Signin2</title></head>
<body>
<BODY BGCOLOR="#228B22">
<%
String Username = request.getParameter("Username");
String Password = request.getParameter("Password");
System.out.println(Username);
System.out.println(Password);
String accessLevel = "";
String password = "";
String username ="root";
String access = "";
System.out.println(Username);
System.out.println(Password);
System.out.println(accessLevel);
try {
Class.forName("com.mysql.jdbc.Driver");
}
catch(ClassNotFoundException xyz) {}
try{
c = DriverManager.getConnection(connectionURL,username, password);
PreparedStatement p = c.prepareStatement("SELECT * from customerdetails where Username ='" + Username+"'");
rs = p.executeQuery();
while(rs.next())
{
pw = rs.getString("Password");
System.out.println(pw);
acc = rs.getString ("access");
out.println(acc);
}
if(rs == null)
{
System.out.println("Wrong information was entered");
%>
<jsp:include page = "error.jsp"/> <%--display this page on the current page--%>
<%
}
}
catch(SQLException tr){
tr.printStackTrace();
}
System.out.println(pw + "really is" + Password);
if(Password.equals(pw))
{
if(acc.equals("Administrator"))
{
System.out.println("Access Level OK");
%>
<jsp:include page = "Admin.jsp"/> <%--display this page on the current page--%>
<%
}
if(acc.equals("User"))
{
System.out.println("Access Level OK");
%>
<jsp:include page = "ProductPetShop.jsp"/><%--display this page on the current page--%>
<%
}
}
else{
System.out.println("blah");
%>
<jsp:include page = "error.jsp"/>
<%
}
%>