我一直在谷歌上搜索现在有一阵子,我仍然无法找到答案,我的问题比较用户输入.. 是:我想知道如果有一个方法或方式来获得数据库的价值,然后比较它...我真的不知道如何解释它..所以我想我会告诉你我的代码到目前为止。顺便说一句使用netbean来制作这个程序,并使用odbc数据库即时通讯(mircosoft访问)。林还使用尝试捕捉的代码,但IDK的如何使其显示..登录 - 数据库
下面的程序并没有真正的工作,我希望它too..since我有比较问题的方式。 在此先感谢。
if(request.getParameter("username")!=null && request.getParameter("username") !=""
&& request.getParameter("password")!=null && request.getParameter("password")!=""){
String user = request.getParameter("username").toString();
String pass = request.getParameter("password").toString();
String check = "SELECT AccountType FROM Testing WHERE Username='"+user+"' AND Password ='"+pass+"'";
rs = stmt.executeQuery(check);
String info = rs.getString(check); // trying to get the AccountType and store it into a string
while(rs.next()){
if(info != null && info !=""){ //checks to see if the account exist in the database
if(info.equals("Admin")){ //checks to see if AccountType is "Admin"
response.sendRedirect("AdminConsole.jsp");
}else
response.sendRedirect("UserConsole.jsp");
}else
response.sendRedirect("ErrorPage2.jsp");
}
}else
response.sendRedirect("ErrorPage.jsp");
connection.close();
}
您有一个SQL注入漏洞。 – SLaks 2011-12-15 19:06:17
你不应该以纯文本存储密码。 – SLaks 2011-12-15 19:06:39