<%String cust_id = request.getParameter("cust_id");
session.setAttribute("cust_id",cust_id);
String cust_code = request.getParameter("cust_code");
String drivername="com.microsoft.sqlserver.jdbc.SQLServerDriver";
String url="jdbc:sqlserver://127.0.0.1:1433;databasename=Information System Design";
String user="sa";
String pwd="7628475";
Class.forName(drivername);
Connection conn = DriverManager.getConnection(url,user,pwd);
Statement stmt = conn.createStatement();//從資料庫里面取東西對比
String sql = "select * from customer where cust_id='"+cust_id+"'and cust_code='"+cust_code+"'";
ResultSet i = stmt.executeQuery(sql);
if(i.next())
{
response.setHeader("refresh","1;url = login。jsp");//跳轉到成功頁面
}
else
{
out.println(i.next()+"ff");
out.println("<script language = 'javaScript'> alert('密碼錯誤,請重新輸入用戶名!');</script>");
response.setHeader("refresh","1;url = sgin_re.html");//回傳登陸頁面
}
stmt.close();
conn.close();
%>
uj5u.com熱心網友回復:
把sql列印出來執行以下,就知道賬號密碼是否真的正確轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/73002.html
標籤:Web 開發
