28,390
社区成员
发帖
与我相关
我的任务
分享
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>用户登陆 </title>
</head>
<body>
<%
if trim(request.Form("userid")) <>"" and trim(request.Form("userpw")) <>"" then '如果用户名密码不为空才查询数据库
On Error Resume Next
Dim Conn,ConnStr
ConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath("db1.mdb")
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.connectionstring = ConnStr
Conn.open
If Err Then
Err.Clear
Conn.close()
Set Conn = Nothing
Response.Clear()
Response.Write "数据库连接出错!"
Response.End
End If
Dim myComm,rs,myRs
on error resume next
Set myComm = Server.CreateObject("ADODB.COMMAND")
With myComm
.ActiveConnection = Conn
.CommandText = "select top 1 * from admin where [Username]='"&trim(request.Form("userid"))&"' and [Password]='"&trim(request.Form("userpw")) &"'"
.CommandType = &H0001
.Prepared = true
End With
set rs = myComm.Execute()
if not err and not(rs.eof or rs.bof) then
Response.write("用户名密码正确登录成功!")
else
Response.write("用户名密码错误登录失败!")
end if
rs.close
set rs = nothing
Conn.close
set Conn = nothing
%>
<form id="form1" name="form1" method="post" action="">
<table width="251" border="0" align="center">
<tr align="center">
<td colspan="2" bgcolor="#0066FF"> <p class="STYLE1">用户登陆 </p> </td>
</tr>
<tr>
<td width="66"> <span class="STYLE4">用户名: </span> </td>
<td width="175"> <span class="STYLE4">
<label>
<input name="userid" type="text" id="userid" />
</label>
</span> </td>
</tr>
<tr>
<td> <span class="STYLE4">密 码: </span> </td>
<td> <span class="STYLE4">
<label>
<input name="userpw" type="password" id="userpw" />
<br />
</label>
</span> </td>
</tr>
<tr align="center">
<td colspan="2"> <span class="STYLE4">
<label>
<input type="submit" name="cmdok" id="cmdok" value="登陆" />
<input type="reset" name="cmdcancel" id="cmdcancel" value="取消" />
</label>
</span> </td>
</tr>
</table>
</form>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>用户登陆 </title>
<style type="text/css">
<!--
.STYLE1 {
font-size: 18px
}
.STYLE4 {font-size: 14px}
body {
margin-top: 200px;
}
-->
</style>
</head>
<body>
<%if trim(request.Form("userid")) <>"" and trim(request.Form("userpw")) <>"" then
dim siteconn,siters,siteexec
set siteconn =server.createobject("adodb.connection")
set siters=server.createobject("adodb.recordset")
siteconn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("sitedata/sitedata.mdb")
siteexec="select * from rxadmin where rxid='"&trim(request.Form("userid"))&"'"
siters.open siteexec,siteconn,1,1
%>
<% if not siters.bof then
If siters("rxpw")=trim(request.Form("userpw")) Then
Response.Redirect("loginok.asp")
else
response.Redirect("loginbad.asp") '密码不正确返回重新登陆
end if
else
response.Redirect("loginbad.asp") '用户名不正确返回重新登陆
end if
else
%>
<form id="form1" name="form1" method="post" action="">
<table width="251" border="0" align="center">
<tr align="center">
<td colspan="2" bgcolor="#0066FF"> <p class="STYLE1">用户登陆 </p> </td>
</tr>
<tr>
<td width="66"> <span class="STYLE4">用户名: </span> </td>
<td width="175"> <span class="STYLE4">
<label>
<input name="userid" type="text" id="userid" />
</label>
</span> </td>
</tr>
<tr>
<td> <span class="STYLE4">密 码: </span> </td>
<td> <span class="STYLE4">
<label>
<input name="userpw" type="password" id="userpw" />
<br />
</label>
</span> </td>
</tr>
<tr align="center">
<td colspan="2"> <span class="STYLE4">
<label>
<input type="submit" name="cmdok" id="cmdok" value="登陆" />
<input type="reset" name="cmdcancel" id="cmdcancel" value="取消" />
</label>
</span> </td>
</tr>
</table>
</form>
<%end if %>
</body>
</html>