当前位置:首页 » 操作系统 » asp登陆界面源码

asp登陆界面源码

发布时间: 2025-04-27 07:25:19

A. 求ASP登陆界面的源码

<%dim db,conn,connstr
db="数据库路劲"
set Conn = server.CreateObject("ADODB.Connection")
connstr="provider=microsoft.jet.oledb.4.0;Persist Security Info=False;data source=" & server.MapPath(db)
conn.Open connstr
IF Request("action")="login" Then verifycode=cstr(request("verifycode"))
if cstr(session("verifycode"))<>verifycode then
session("verifycode")=""
Response.Write("<script language=javascript>alert('请输入正确的认证码!');this.location.href='login.asp';</script>")
Response.End
else
session("verifycode")=""
end if

user=replace(trim(request.form("uName")),"'","''")
password=replace(trim(request.form("Password")),"'","''")
if instr(user,"%") or instr(user,"#") or instr(user,"?") or instr(user,"|") or instr(user,"'") then
response.write "<script language=javascript>alert('您的姓名含有非法字符!');this.location.href='login.asp';</script>"
response.end
end if

if instr(password,"%") or instr(password,"#") or instr(password,"?") or instr(password,"|") then
response.write "<script language=javascript>alert('您的密码含有非法字符!');this.location.href='login.asp';</script>"
response.end
end if

uName=Trim(Request.Form("uName"))
Password=Trim(Request.Form("Password"))
IF uName<>"" And Password<>"" Then
SQL="Select * From adminname Where adminname='"& uName &"'"
Set RS=Server.CreateObject("ADODB.REcordset")
RS.Open SQL,Connstr,1,3
IF Not RS.Eof Then
IF Password=RS("adminpassword") Then
if rs("jb")="高级管理员" then
Session("cwz_youth1710")=uName
Session("cwz_youth1710_zj")=uName
Session("cwz_youth1710_dj")=uName
rs("LoginTimes")=rs("LoginTimes")+1
rs("LoginTime")=now()
rs("LoginIP")=Request.ServerVariables("REMOTE_ADDR")
rs.Update
Response.Redirect "index.asp"
elseif rs("jb")="中级管理员" then
Session("cwz_youth1710_zj")=uName
Session("cwz_youth1710_dj")=uName
rs("LoginTimes")=rs("LoginTimes")+1
rs("LoginTime")=now()
rs("LoginIP")=Request.ServerVariables("REMOTE_ADDR")
rs.Update
Response.Redirect "index.asp"
elseif rs("jb")="低级管理员" then
Session("cwz_youth1710_dj")=uName
rs("LoginTimes")=rs("LoginTimes")+1
rs("LoginTime")=now()
rs("LoginIP")=Request.ServerVariables("REMOTE_ADDR")
rs.Update
Response.Redirect "index.asp"
end if
else
response.write("<script language=javascript>alert('密码错误!');this.location.href='login.asp';</script>")
response.end
End IF
else
response.write("<script language=javascript>alert('用户名不存在!');this.location.href='login.asp';</script>")
response.end
End IF
else
response.write("<script language=javascript>alert('用户名或密码不能为空!');this.location.href='login.asp';</script>")
End IF
End IF Function getcode1()
Dim test
On Error Resume Next
Set test=Server.CreateObject("Adodb.Stream")
Set test=Nothing
If Err Then
Dim zNum
Randomize timer
zNum = cint(8999*Rnd+1000)
Session("verifycode") = zNum
getcode1= Session("verifycode")
Else
getcode1= "<img src=""getcode.asp"">"
End If
End Function

%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>韶关学院50周年校庆网站后台管理登陆页面</title>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
body,td,th {
font-size: 12px;
}
-->
</style></head><body><div align="center">
<table width="770" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="486"> <div align="center">
<form action="login.asp?action=login" method="post">
<table width="300" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="88" height="30"><div align="right">用户名:</div></td>
<td colspan="2"><input type=text name="uName" size=12 maxlength=20 style="background-attachment: scroll; background-repeat: repeat; font-size: 9pt; height: 18; width: 102; background-color: #FFFFFF; border: 1 solid #000000; background-position: none 0%"></td>
</tr>
<tr>
<td height="30"><div align="right">密码:</div></td>
<td height="18" colspan="2"><input type=password name="Password" size=12 maxlength=16 style="background-attachment: scroll; background-repeat: repeat; font-size: 9pt; height: 18; width: 102; background-color: #FFFFFF; border: 1 solid #000000; background-position: none 0%"></td>
</tr>
<tr>
<td height="30"><div align="right">认证码:</div></td>
<td width="112" height="30"><input class="input" type="text" name="verifycode" size="20" style="background-attachment: scroll; background-repeat: repeat; font-size: 9pt; height: 18; width: 102; background-color: #FFFFFF; border: 1 solid #000000; background-position: none 0%"></td>
<td width="100"><%=getcode1()%></td>
</tr>
<tr>
<td height="30" colspan="3"><div align="center"><font color="#000000">
<input type=submit value=' 提 交 ' name=Submit style="background-color: #DDDDDD; background-repeat: repeat; background-attachment: scroll; font-size: 9pt; height: 20; width: 50; border: 1px groove #000000; background-position: 0% 50%">

<input type=reset value=' 取 消 ' name=Submit style="background-color: #DDDDDD; background-repeat: repeat; background-attachment: scroll; font-size: 9pt; height: 20; width: 50; border: 1px groove #000000; background-position: 0% 50%">
</font></div></td>
</tr>
</table>
</form>
</div></td>
</tr>
</table>
</div>
</body>
</html>

B. ASP 用户登陆验证源码

member.asp:
在页面头部加一个判断就可以了:
<%
if Session("Uid")="" or Session("ifUserLogin")<>1 then
Response.redirect"login.asp"
else

'页面代码开始

end if
%>

Login.asp:
为了简化程序,把登陆提交页面和后台验证程序放在同一个页面中:

<!--#include file="Conn.asp"-->
<!--#include file="Md5.asp"-->
<%
'注:第一句是调用数据库连接代码,第二句代码是为了调用函数给密码加密
'请确保你的网站目录下有这个文件,没有的话可以从网上下载一个。

Dim Action
action=Trim(Request("action"))
if action="ChkLogin" then
call ChkLogin()
else
call UserLogin()
end if

Sub UserLogin
'用户提交表单代码开始
Response.write"<form action='Login.asp?action=ChkLogin' method='post'>"
Response.write"<table width='300' border='0' cellspacing='0' cellpadding='0'>"
Response.write"<tr>"
Response.write"<td width='80'>用户名:</td>"
Response.write"<td width='220'><input type='text' name='UID'></td>"
Response.write"</tr>"
Response.write"<tr>"
Response.write"<td width='80'>密 码:</td>"
Response.write"<td width='220'><input type='password' name='Pwd'></td>"
Response.write"</tr>"
Response.write"<tr>"
Response.write"<td colspan='2' align='center'><input type='submit' value='登录'><input

type='reset' value='取消'></td>"
Response.write"</tr>"
Response.write"</table>"
Response.write"</form>"
End Sub

Sub ChkLogin()
'后台验证部分开始
'因为每一个验证码的验证机制不同,
'所以省略了对验证码的判断。

Dim Rs,SQL,UID,PWD
UID=Trim(Request.form("uid"))
PWD=MD5(Request.form("pwd")) '这里调用了MD5给密码加密
if UID="" Or PWD="" then
Response.write"<script language='Javascript'>alert('用户名密码不能为空');history.back(-1);</Script>"
Set Rs=server.CreateObject("adodb.recordset")
SQL="select * from [hyuser] where Uid='"&UID&"' and PWD='"&PWD&"' "
Rs.open SQL,conn,1,1
if Rs.eof or Rs.bof then
Response.write"<script language='Javascript'>alert('密码错误!');history.back(-1);</Script>"
else
Session("uid")=UID
Session("ifUserLogin")=1
Response.redirect"member.asp"
end if
Set Rs=nothing
End Sub

%>

热点内容
雷神电脑不激活系统配置怎么查 发布:2025-04-27 16:09:06 浏览:721
亚马逊a9算法是什么 发布:2025-04-27 16:01:57 浏览:926
oppo手机指纹密码忘了怎么办 发布:2025-04-27 15:51:57 浏览:534
安卓抖音怎么录屏别人的直播 发布:2025-04-27 15:49:27 浏览:6
c语言静态变量定义 发布:2025-04-27 15:47:58 浏览:731
湖北十堰服务器ip物理机 发布:2025-04-27 15:47:49 浏览:309
压缩视频好处 发布:2025-04-27 15:39:42 浏览:518
车载安卓系统如何添加输入法 发布:2025-04-27 15:38:44 浏览:74
全国计算机二级等级考试c语言 发布:2025-04-27 15:34:50 浏览:508
脚本战舰少女 发布:2025-04-27 15:26:59 浏览:549