📄 login_ok.jsp
字号:
<%@ page contentType="text/html;charset=gb2312" %>
<%@page language="java" import="java.sql.*"%>
<jsp:useBean id="userBean" scope="page" class="webmail.conn"/>
<%!
public String getStr(String str)
{
try
{
String temp_p=str;
byte[] temp_t=temp_p.getBytes("ISO8859-1");
String temp=new String(temp_t);
return temp;
}
catch(Exception e)
{
}
return "null";
}
%>
<%!
String logname,logpass;
boolean loginAttempt = false;
boolean loginOK = false;
String errorMessage = "请您登陆";
%>
<%
if(request.getParameterValues("login") != null
&&request.getParameterValues("logname") != null
&&request.getParameterValues("logpass") != null)
{
loginAttempt = true;
}
if (loginAttempt)
{
logname=request.getParameter("logname");
logpass=request.getParameter("logpass");
logname=getStr(logname);
logpass=getStr(logpass);
String sql="select * from member where logname='"+logname+"' and password='"+logpass+"'";
//out.println(sql);
ResultSet RS=userBean.executeQuery(sql);
int rowscount=0;
try
{
while(RS.next())
{
rowscount++;
}
}
catch(Exception e)
{
}
//count.........
// out.println(rowscount);
if(rowscount!=0)
{
errorMessage="成功登陆";
session.setAttribute("username",logname);
loginOK=true;
if(loginOK){
response.sendRedirect("main.jsp");
}
}else{
errorMessage="您的用户名或者密码不正确";
session.setAttribute("username","");
}
}
%>
<table align="center" border="0" width="760" cellspacing="0" cellpadding="0" height="355">
<tr>
<td width="150" height="355" valign="top">
</td>
<td width="10" height="100%"></td>
<td width="1" height="100%" bgcolor="#3399ff"></td>
<td width="10" height="100%"></td>
<td width="589" height="331" valign="top" background="images/bg1.gif">
<table border="0" width="100%" cellspacing="0" cellpadding="0" height="307">
<tr>
<td width="100%" colspan="2" height="20" bgcolor="#3399ff"> <font color="#ffffff">成员登录</font>
</td>
</tr>
<tr><td align="right" height="32" width="40%">
<font color=red><%=errorMessage%></font>
</td>
</tr>
<form action="" method="post">
<tr><td align="right" height="32" width="40%">名字:</td>
<td>
<input type="hidden" name="returl" value="">
<input type="text" name="logname" value="">
</td>
</tr>
<tr>
<td align="right" height="32">密码:</td>
<td>
<input type="password" name="logpass">
</td>
</tr>
<tr>
<td align="center" colspan="2" height="32"> |
<a href="findpass.jsp">密码忘了,找一下</a> |
<a href="reg.jsp">注册新用户</a> |
<input type="submit" name="login" value="GO!">
</td>
</tr>
</form>
<tr>
<td colspan="2" align="right"> </td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -