5ucms论坛
标题:
8、POPASP快速入门第八课 验证码与登陆模块
[打印本页]
作者:
admin
时间:
2019-4-1 16:07
标题:
8、POPASP快速入门第八课 验证码与登陆模块
login.asp
<!--#include file="../popasp_2.0/popasp.asp"-->
<%
'项目部署时不要手工去创建home文件夹,系统会自动创建该文件夹
const APP_PATH = "./home"
'项目部署的时候使用POP_MVC.start方法,项目部署完之后使用POP_MVC.run方法
POP_MVC.run
%>
<%
Call A_("Index/login")
%>
<html>
<head>
<title>使用了验证码的登陆模块</title>
</head>
<body style="margin:0 auto;text-align:center;">
<h1 style="margin-top:100px;">登陆系统</h1>
<form action="login.asp?c=Index&a=do_login" method="post">
<p>用户名:<input type="text" name="username"></p>
<p>密码:<input type="password" name="password"></p>
<p>验证码:<input type="text" name="verify" /><img src="login.asp?c=Public&a=verify" style="height:14px;" onclick="javascript:this.src='login.asp?c=Public&a=verify&tm='+Math.random();" title="看不清,点击验证码更换一张" /></p>
<p><input type="submit" name="send" value="登陆"></p>
</form>
</body>
</html>
复制代码
IndexAction.class.asp
<%
' 本类由系统自动生成,仅供测试用途
Class IndexAction
public Sub index()
Response.write "<h1 style=""font-size:80px;margin:30px 0 10px 30px;font-family:'微软雅黑';font-weight: normal;"">:)</h1><p style=""line-height:1.8em;font-size: 36px;margin:0 0 0 30px;font-family:'微软雅黑';font-weight: normal;"">欢迎使用 <b>POPASP</b>!</p>"
end Sub
sub do_login
dim rs,where
'验证码存于session中,对应的是session("verify")
'that.form与that.get类似,它是request.form的简写
if session("verify") <> that.form("verify") then
'失败操作的方法that.error
that.error( "验证码错误" )
end if
'创建一个Dictionary对象
set where = D_
where("username") = that.form("username")
'在POPASP中有现成的md5函数
where("password") = md5( that.form("password") )
set rs = M_("user").db.where( where ).find()
if rs.eof then
that.error( "用户名或密码错误" )
else
'成功操作使用that.success
that.success( array( "登陆成功" , "admin/index.asp" ) )
end if
response.end
end sub
End Class
%>
复制代码
PublicAction.class.asp
<%
Class PublicAction
sub verify
'在POPASP中有一个基类POPASP_VERIFY
'在POPASP_CONTROLLER类中有一个方法verify
call that.verify
'var_export that
end sub
End Class
%>
复制代码
欢迎光临 5ucms论坛 (http://bbs.5ucms.com/)
Powered by Discuz! X3.2