📄 do_login.jsp
字号:
<%@ page contentType="text/html; charset=gb2312" %>
<%@ page import="java.sql.*" %>
<html><body>
<%
request.setCharacterEncoding("GBK");
Statement stmt=null;
Connection conn=null;
ResultSet rs=null;
String strusername=request.getParameter("username");
String strpasswd=request.getParameter("passwd");
String strSql="";
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException ce)
{
out.print(ce.getMessage());
}
conn=DriverManager.getConnection("jdbc:odbc:webbook");
stmt=conn.createStatement();
strSql="select * from shop_user where UserName='"+strusername+"' and PassWord='"+strpasswd+"'";
rs=stmt.executeQuery(strSql);
if(rs.next())
{
session.setAttribute("jack","SleepDragon");
response.sendRedirect("to_login.jsp");
}
else
{
%>
<script language="javascript">
alert('用户名或密码错误!');
history.go(-1);
</script>
<%
} %>
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -