5ucms论坛

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 6374|回复: 0
打印 上一主题 下一主题

[2.x] 8、POPASP快速入门第八课 验证码与登陆模块

[复制链接]

670

主题

785

帖子

8228

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
8228
跳转到指定楼层
楼主
发表于 2019-4-1 16:07:13 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
login.asp
  1. <!--#include file="../popasp_2.0/popasp.asp"-->
  2. <%

  3. '项目部署时不要手工去创建home文件夹,系统会自动创建该文件夹
  4. const APP_PATH = "./home"

  5. '项目部署的时候使用POP_MVC.start方法,项目部署完之后使用POP_MVC.run方法
  6. POP_MVC.run
  7. %>
  8. <%
  9. Call A_("Index/login")
  10. %>
  11. <html>
  12. <head>
  13. <title>使用了验证码的登陆模块</title>
  14. </head>
  15. <body style="margin:0 auto;text-align:center;">
  16. <h1 style="margin-top:100px;">登陆系统</h1>

  17. <form action="login.asp?c=Index&a=do_login" method="post">

  18.         <p>用户名:<input type="text" name="username"></p>
  19.         <p>密码:<input type="password" name="password"></p>
  20.         <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>
  21.         <p><input type="submit" name="send" value="登陆"></p>
  22. </form>
  23. </body>
  24. </html>
复制代码



IndexAction.class.asp
  1. <%
  2. ' 本类由系统自动生成,仅供测试用途
  3. Class IndexAction
  4.     public Sub index()
  5.                 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>"
  6.     end Sub
  7.        
  8.         sub do_login
  9.                 dim rs,where
  10.        
  11.                 '验证码存于session中,对应的是session("verify")
  12.                 'that.form与that.get类似,它是request.form的简写
  13.                 if session("verify") <> that.form("verify") then
  14.                         '失败操作的方法that.error
  15.                         that.error( "验证码错误" )
  16.                 end if
  17.                
  18.                 '创建一个Dictionary对象
  19.                 set where = D_
  20.                
  21.                 where("username") = that.form("username")
  22.                
  23.                 '在POPASP中有现成的md5函数
  24.                 where("password") = md5( that.form("password") )
  25.                
  26.                 set rs = M_("user").db.where( where ).find()
  27.                
  28.                 if rs.eof then
  29.                         that.error( "用户名或密码错误" )
  30.                 else
  31.                         '成功操作使用that.success
  32.                         that.success( array( "登陆成功" , "admin/index.asp" ) )
  33.                 end if
  34.                
  35.                 response.end
  36.         end sub
  37. End Class
  38. %>
复制代码


PublicAction.class.asp
  1. <%
  2. Class PublicAction
  3.         sub verify
  4.                 '在POPASP中有一个基类POPASP_VERIFY
  5.                 '在POPASP_CONTROLLER类中有一个方法verify
  6.                 call that.verify
  7.                 'var_export that
  8.         end sub
  9. End Class
  10. %>
复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|5ucms.com

GMT+8, 2024-4-19 22:04 , Processed in 0.531250 second(s), 29 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表