我一直在谷歌上搜索現在有一陣子,我仍然無法找到答案,我的問題比較用戶輸入.. 是:我想知道如果有一個方法或方式來獲得數據庫的價值,然後比較它...我真的不知道如何解釋它..所以我想我會告訴你我的代碼到目前爲止。順便說一句使用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