都市桃源空间txt下载:在线急等!请求ASP代码的用户登陆代码

来源:百度文库 编辑:查人人中国名人网 时间:2024/04/29 04:31:10
请求ASP代码的用户登陆代码 ACCESS数据库

'news_dl.asp
<!--#include file="conn.asp"-->
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
<title>登陆</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head>
<body>
<table width="778" border="0" cellspacing="0" cellpadding="0" background="images/top-back.gif" align="center">
<tr>
<td height="74" align="center" width="190"><img src="images/logo.gif" width="78" height="74"></td>
<td align="center" height="74"><font color="#E3E9F1" size="6" face="华文行楷"><%=bb%></font></td>
</tr>
</table>
<table width="778" border="1" cellspacing="0" cellpadding="0" bgcolor="#7894AF" align="center">
<tr bgcolor="#eeeeee">
<td height="25" ><%=why%>   欢迎来到 <%=bb%>!</td>
</tr>
</table>
<p>
<%yhm=request.form("yhm")
pass=request.form("pass")
if yhm<>"" and pass<>"" then
set rs=server.createobject("adodb.recordset")
exec="select * from admin where yhm='"+yhm+"'"
rs.open exec,conn,1,1
if not rs.eof then
if setpwd(pass)<>rs("pass") then response.redirect "news_dl.asp"
else
response.redirect "news_dl.asp"
end if
session("newspass") = pass
session("newsyhm") = rs("yhm")
rs.close
conn.close
response.redirect "news_admin.asp"
end if%>
<br>
</p>
<form name="from" method="post" action="news_dl.asp?dz=<%=dz%>">
<table align="center">
<tr>
<td> 用户名</td>
<td>
<input type="text" name="yhm" size="10" maxlength="10"></td>
</tr>
<tr>
<td>密 码</td>
<td>
<input type="password" name="pass" size="10" maxlength="10"> </td>
</tr>
</table>
<table cellpadding="4" cellspacing="0" align="center">
<tr>
<td align="center">
<input type=submit onclick="javascript:return dl(yhm.value,pass.value);" value="登 陆">
    
<input type="button" value="返 回" onClick="javascript:window.location='news.asp';">
</td>
</tr>
</table>
</form>
</center>
</body>
</htm>
<script language='javascript'>
function dl(yhm,pass)
{
if (yhm=="")
{alert('输入用户名!');
document.from.yhm.focus();
return false;}
if (pass=="")
{alert('输入密码!');
document.from.pass.focus();
return false;}}
</script>

'conn.asp
<%on error resume next
set conn=server.createobject("adodb.connection")
conn.open "Provider=Microsoft.Jet.OLEDB.4.0;User Id=admin;jet OleDB:Database Password=abcdefg;Data Source="& Server.MapPath("news.mdb")%>

If CheckStr(Request("Action")) = "Login" Then
Call OpenConn(Conn)
If CheckUserExits(CheckStr(Request("UserName"))) = True Then
If CheckUserPassWord(CheckStr(Request("UserName")),MD5(CheckStr(Request("PassWord")),16)) = True Then
Session("UserName") = CheckStr(Request("UserName"))
Response.Write "<script>alert('OK,用户["&Session("UserName")&"]登录成功!');location.href='LoginSuccess.asp';</script>"
Else
Response.Write "<script>alert('对不起,密码不正确,请重新输入!');history.go(-1);</script>"
End If
Else
Response.Write "<script>alert('对不起,无此用户,请重新输入!');history.go(-1);</script>"
End If
Call CloseConn()