do_login.jsp

来自「一个功能极其简单的网上书店系统」· JSP 代码 · 共 55 行

JSP
55
字号
<%@ 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 + =
减小字号Ctrl + -
显示快捷键?