28,391
社区成员
发帖
与我相关
我的任务
分享
<html>
<head>
<title>用户登录</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script language="javascript">
function chk()
{
var user=document.form1.user.value;
user=user.replace(/ /g,"");
user=user.replace(/ /g,"");
var pass=document.form1.pass.value;
pass=pass.replace(/ /g,"");
pass=pass.replace(/ /g,"");
if(user=="")
{
alert("必须输入用户名才能登陆。");
document.form1.user.value="";
document.form1.user.focus();
return false;
}
if(pass=="")
{
alert("必须输入密码才能登陆。");
document.form1.pass.value="";
document.form1.pass.focus();
return false;
}
return true;
}
</script>
</head>
<body style="text-align:center">
<h2 style="font-family:楷体_GB2312">用户登录</h2>
<form name="form1" method="post" action="login.asp" onSubmit="return chk();">
<table border="1" bordercolor="#CCCCCC" width="300" cellpadding="0" cellspacing="0" style="border-collapse:collapse;">
<tr>
<td height="35" align="center">用户名:</td>
<td> <input type="text" name="user" style="width:130px;height:22px" /> </td>
</tr>
<tr>
<td height="35" align="center">密 码:</td>
<td> <input type="password" name="pass" style="width:130px;height:22px" /></td>
</tr>
<tr>
<td colspan="2" height="40" align="center"> <input type="submit" value=" 提交 " /> <input type="reset" value=" 重填 " /> </td>
</tr>
</table>
<p><a href="reg.htm">新用户注册</a></p>
</form>
</body>
</html>
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
Set conn=Server.CreateObject("ADODB.Connection")
connstr="driver={Microsoft Access Driver (*.mdb)};dbq="&Server.MapPath("db1.mdb")
conn.Open connstr
dim ok,user,pass,sex,msg
ok=false
msg="登录失败"
user=request.form("user")
pass=request.form("pass")
Set rs=Server.CreateObject("ADODB.Recordset")
sql="SELECT * FROM [reg] WHERE user='"&user&"'"
rs.Open sql,conn,1,1
If Not rs.EOF Then
If pass=rs("password") Then
ok=True
msg="登录成功"
If rs("sex")=1 then
sex="女士"
Else
sex="先生"
End If
end if
End If
rs.close
conn.close
set rs=nothing
set conn=nothing
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title><%=msg%></title>
</head>
<body style="text-align:center">
<h2><%=msg%></h2>
<hr size="1" color="black" />
<% If ok=True Then %>
<p> <a href="forum.asp">进入主页</a> </p>
<p> <a href="chat.asp">进入聊天室</a> </p>
<p> <a href="chess.asp">进入棋牌室</a> </p>
<p> <a href="modify.asp">修改密码及个人信息 </a> </p>
<% Else %>
<p>请重新输入正确的用户名和密码!</p>
<p> <a href="defaule.htm">返回</a> </p>
<% End If %>
</body>
</html>
<SCRIPT LANGUAGE="JavaScript">
//javascript语句要加分号。
function chk()
{
if(document.form1.user.value.length==0)
alert("必须输入用户名才能登陆。");
else if(document.form1.pass.value.length==0)
alert("必须输入密码才能登陆。") ;
else
document.form1.submit();
}
</SCRIPT>