一只牛の窝

生命只是在演绎着自己的精彩,分享才是最大的快乐……

« 通过ASP禁止指定IP和只允许指定IP访问网站JS随机函数及应用于随机广告方法 »

ASP代码做一个不关联数据库的密码登陆页面及应用于加密附件方法

一、不关联数据库的密码登陆页面ASP代码:

<% 
password="ycjan" '登陆密码修改处
flag=Trim(Request.QueryString("flag"))
if flag="0" then
if Trim(Request.Form("user"))=password then
response.Cookies("login")="ycjan"  'ycjan 为 Cookies 名
end if
end if
user=request.Cookies("login")
id=Trim(Request.QueryString("id"))
if user="" then 
Response.Write("<form name=""myform"" action=""?flag=0"" method=""post""><table width=""500"" height=""300"" border=""0"" align=""center"" cellpadding=""0"" cellspacing=""0""><tr><td align=""center"">请输入密码(ycjan):<input name=""user"" type=""password"" id=""user""><input type=""submit"" name=""Submit"" value=""  确 定   ""></td></tr></table></form>")
response.End()
else
Response.Write("登陆成功") '登陆成功进行相应操作
end if 
%>

二、把上面代码加强一点,举一个例子,做一个简单页面的要登陆才能查看或下载:

<% 
password="ycjan" '登陆密码修改处
url=request("url")
flag=Trim(Request.QueryString("flag"))
if flag="0" then
if Trim(Request.Form("user"))=password then
response.Cookies("login")="ycjan"  'ycjan 为 Cookies 名
end if
end if
user=request.Cookies("login")
id=Trim(Request.QueryString("id"))
if user="" then 
Response.Write("<form name=""myform"" action=""?flag=0&url="+url+""" method=""post""><table width=""500"" height=""300"" border=""0"" align=""center"" cellpadding=""0"" cellspacing=""0""><tr><td align=""center"">请输入密码:<input name=""user"" type=""password"" id=""user""><input type=""submit"" name=""Submit"" value=""  确 定   ""></td></tr></table></form>")
response.End()
else
response.redirect "http://www.baidu.com/img/"+url
'Response.Write("登陆成功") '登陆成功进行相应操作
end if 
%>

使用方法如:把下面的代码另存为file.asp,分别新开IE打开file.asp?url=logo-yy.gif,及file.asp?url=baidu_logo.gif然后打入密码可以以查看附件,这只是举例这个代码还可以作为加密下载文件也同样是可以的。


原创文章如转载,请注明:转载自 阳春一月 [ http://blog.ycjan.com/ ]

本文链接地址:http://blog.ycjan.com/asp/20090523340.html

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

日历

Search

最近发表

Powered By Z-Blog 1.8 Arwen Build 81206

Copyright ycjan.com 粤ICP备08002314号