chklogin.jsp
来自「论坛源码」· JSP 代码 · 共 42 行
JSP
42 行
<%@ page contentType="text/html; charset=gb2312" language="java" errorPage="" %>
<%@ include file="incdb.jsp"%>
<jsp:useBean id="conn" class="twm.bbsreg" scope="page"/>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>登录</title>
</head>
<body>
<%
String sql="";
ResultSet rs;
String username=request.getParameter("username");
String password=request.getParameter("password");
if(username!=null&&!username.equals("")){
try{
sql="select * from user where username='" + username + "' and userpassword='" + password + "'";
rs=conn.executeQuery(sql);
if(rs.next()){
session.setAttribute("login","ok");
session.setAttribute("username",username);
%>
<jsp:forward page="index1.jsp"/>
<%
}else
out.println("错误的用户名或密码");//验证未通过,显示错误信息。
out.println("<a href=login.jsp>返回</a>");
}catch(Exception ee){
ee.printStackTrace();
}
}else{
out.println("请先登录!");
out.println("<a href=login.jsp>返回</a>");
}
%>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?