Thursday 15 April 2010

mysql - How to login user and Admin in same page -



mysql - How to login user and Admin in same page -

i trying login username , password in way.based on input values pages should redirect.but not able login.

<%@include file="database.jsp" %> <% string user = request.getparameter("user"); string pass = request.getparameter("pass"); if (user.equals("admin") && pass.equals("admin123")) { response.sendredirect("adminhome.jsp"); } else { response.sendredirect("adminerror.jsp"); } if (user != "admin") { string sql = "select * user username='" + user + "' , password='" + pass + "'"; rs = st.executequery(sql); if (rs.next()) { response.sendredirect("userhome.jsp"); } else { response.sendredirect("usererror.jsp"); } } %>

you using scriplet when should utilize servlets. servlets simpler write, test , debug scriplets.

in code, never reach user part. either give right admin user , pass , should redirected adminhome.jsp, else pass through response.sendredirect("adminerror.jsp");

if user admin should redirected adminhome.jsp (provided there nil else after show). else phone call twice sendredirect should cause error.

you should @ to the lowest degree test separately user , password admin part avoid response.sendredirect("adminerror.jsp"); branch if user not admin , multiple redirection error.

you should seek type straight in browser url adminhome.jsp sure correctly accessible browser.

mysql jsp

No comments:

Post a Comment