最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
用ASP为你的站点加密
时间:2022-07-02 23:56:16 编辑:袖梨 来源:一聚教程网
正在学习建设web站点的读者,可能正在为站点的安全性而担忧;也许你正在建设一个非公开性网站,只有系统用户才可以访问你的站点。如果你编制的是ASP网页,那么你可以通过本文轻松达到这一目的。
首先,你需要制作登录页面,在html中加入form,并设为自发送页
〈form name=″login″ action=″default.ASP″ method=″post″ target=″―top″〉
action后接本页url,这样即使用户登录错误,在本页即获提示,而无须再返回前一页登录。在表单中加入
〈input name=″uid″ size=″10″maxlength=″10″ style=″ ″〉
〈input name=″pwd″ type=″password″ size=″10″ maxlength=″10″〉
完成html后,在页首填加程序代码如下:
〈% ′send customer direct to main page if already logged in
if not isempty(session(″cust―id″)) and len(session(″cust―id″))〉0 then response.redirect(″navigation/dashbrd.ASP″)
′在此添入你真正的主页url
end if
′set flags
blogin = false
berror = false
′check blank entries
if isempty(request(″uid″)) or len(request(″uid″)) = 0 or isempty(request(″pwd″)) or len(request(″pwd″)) = 0 then
′need to log in
blogin = true
else
′check user credentials against db
… ′检验你的数据库保存密码表中是否有该用户
′此处放入连接数据库代码
′其sql如下 ″select * from customer where cust―id=′ ″ & request(″uid″) & ″ ′ and ′cust―pwd=′ ″ & request(″pwd″) & ″ ′ ″
′其中request(″uid″)和request(″pwd″) 为本页html中表单中的用户名和密码的text
gbfound = false
if not rscust.bof and not rscust.eof then
gbfound = true
end if
if gbfound then
′record useful customer info in session variables
session(″cust―id″) = rscust.fields(″cust―id″)
′ 此项为数据库中用户名
session(″cust―pwd″) = rscust.fields(″cust―pwd″) ′此项为数据库中用户密码
session(″power″) = rscust.fields(″power″) ′此项为数据库中用户权限[可选]
′update last login time [可选]
首先,你需要制作登录页面,在html中加入form,并设为自发送页
〈form name=″login″ action=″default.ASP″ method=″post″ target=″―top″〉
action后接本页url,这样即使用户登录错误,在本页即获提示,而无须再返回前一页登录。在表单中加入
〈input name=″uid″ size=″10″maxlength=″10″ style=″ ″〉
〈input name=″pwd″ type=″password″ size=″10″ maxlength=″10″〉
完成html后,在页首填加程序代码如下:
〈% ′send customer direct to main page if already logged in
if not isempty(session(″cust―id″)) and len(session(″cust―id″))〉0 then response.redirect(″navigation/dashbrd.ASP″)
′在此添入你真正的主页url
end if
′set flags
blogin = false
berror = false
′check blank entries
if isempty(request(″uid″)) or len(request(″uid″)) = 0 or isempty(request(″pwd″)) or len(request(″pwd″)) = 0 then
′need to log in
blogin = true
else
′check user credentials against db
… ′检验你的数据库保存密码表中是否有该用户
′此处放入连接数据库代码
′其sql如下 ″select * from customer where cust―id=′ ″ & request(″uid″) & ″ ′ and ′cust―pwd=′ ″ & request(″pwd″) & ″ ′ ″
′其中request(″uid″)和request(″pwd″) 为本页html中表单中的用户名和密码的text
gbfound = false
if not rscust.bof and not rscust.eof then
gbfound = true
end if
if gbfound then
′record useful customer info in session variables
session(″cust―id″) = rscust.fields(″cust―id″)
′ 此项为数据库中用户名
session(″cust―pwd″) = rscust.fields(″cust―pwd″) ′此项为数据库中用户密码
session(″power″) = rscust.fields(″power″) ′此项为数据库中用户权限[可选]
′update last login time [可选]
相关文章
- Yandex网页版访问入口 Yandex搜索引擎官网登录 10-26
- AI漫剧伪装直男1‑24集无雾版夸克网盘资源免费分享 10-26
- 韩漫在线免费漫画入口-最新韩漫免费阅读入口 10-26
- 海角社区最新登录入口-2026海角官网在线登录直达地址 10-26
- mcjs网页版即点即玩-mcjs极速秒玩入口 10-23
- 超星学习通网页版登录-超星学习通官网入口 10-23