染卷不卷'blog

12年站长,AI实践中。互联网 IT行业,工作见闻、技术教程全分享。

程序源码

asp网站登录验证源码(带session)

一个简单的asp登录验证源码,从网上百度的,说实话自己并不会asp。没有连接数据库,只是单纯的使用预设的用户名与密码登录。再附加一个asp网页需要登录后才能访问的源码,其实就是在需要设置登录才能访问的该SAP网页源码前加上一个session判断就可以了!

因为源码都是拼接而成所以有些地方有些调试代码,也没有去删除精简,凑合着用吧。

一共三个asp文件,login.asp实现网站登录界面展示,然后传递用户名与密码给admin.asp验证通过后打开view.asp文件,view.asp前部加上了session判断,如果满足条件就能访问,否则跳回login.asp,好了下面上源码,带数据库验证用户名密码的以后再写吧,用好百度就行!

login.asp

<!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>
</head>
<table width=400 cellspacing=1 cellpadding=5 align=center bgcolor=#CCCCCC>
<tr align=center bgcolor=006699>
<td colspan="2" bgcolor="#333333"><font color="#FFFFFF">博客网站登录</font></td>
</tr>
<form name="login" method="post" action="admin.asp" onsubmit="return checklogin">
<tr bgcolor="#FFFFFF">
<td align="right">帐号:</td>
<td><input type="text" name="username" ></td>
</tr>
<tr bgcolor="#FFFFFF">
<td align="right">密码:</td>
<td><input type="password" name="password" ></td>
</tr>
<tr align="center" bgcolor="#FFFFFF">
<td colspan="2"><input type="submit" onclick="checklogin" name="Submit" value="登陆">
<input type="reset" name="reset" value="重填"></td>
</tr>
<tr align="center" bgcolor="#FFFFFF">
<td colspan="2">ranjuan.cn</td>
</tr>
</form>
 
</table>
 
<body>
</body>
</html>

 

admin.asp

<!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>
</head>
 
<table width=400 cellspacing=1 cellpadding=5 align=center bgcolor=#CCCCCC>
<tr align=center bgcolor=006699>
<%
 
response.buffer=true
Response.Expires=0
username=request("username")
password=request("password")
 
 
'dim username,password
'username=trim(request.Form("username"))
'password=trim(request.Form("password"))
 
'if (password="admin" and username="admin" or session("sysop")=True) then
 
if (password="admin" and username="admin") then
'密码正确,欢迎光临!'
session("sysop")=True
response.redirect "view.asp"
response.end
else
session("sysop")=false
session("alert")="密码或账号不对,请重新输入用户名与密码!"
 
%>
<script language=vbscript>
MsgBox "用户名或密码错误!"
location.href = "javascript:history.back()"
</script>
<%
response.redirect "login.asp"
response.end
end if
%>
 
</tr>
</table>
<body>
</body>
</html>

 

view.asp

<%
 
if session("sysop")<>"True" then
response.Redirect("login.asp")
response.end
end if
 
response.write "hello world!"
%>

 

 

 

 

染卷

本站文章也会定期同步到微信公众号,可以关注下避免错过~

建站 11年 359天
微信公众号

发表评论

邮箱不会公开,带 * 为必填。