1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > asp带验证码的用户登录及校验代码实现

asp带验证码的用户登录及校验代码实现

时间:2020-06-27 11:09:13

相关推荐

asp带验证码的用户登录及校验代码实现

在参考了各种资料之后,实现了用户登录模块。主要难点集中在随机验证码的实现以及验证码在页面间的传递操作。具体实现代码如下:

login.asp:

<%FUNCTIONGEN_KEY(digits)dimchar_array(80)fori=0to9char_array(i)=cstr(i)nextfori=10to35char_array(i)=chr(i+55)nextfori=36to61char_array(i)=chr(i+61)nextrandomizedowhilelen(output)<digitsnum=char_array(int((62-0+1)*rnd+0))outputoutput=output&numloopgen_key=outputendfunction%><html><head></head><body><formname="form1"action="check.asp">用户登录界面:<BR>用户名:<INPUTTYPE=TEXTBOXNAME="TXTNAME"></input><BR>密码:<INPUTTYPE=TEXTBOXNAME="TXTPWD"></input><BR>验证码:<INPUTTYPE=TEXTBOXNAME="TXTYZM"></INPUT><%session("verifycode")=gen_key(4)response.writesession("verifycode")%><BR><inputtype=submitvalue="登录"/><inputtype=resetvalue="重置"/></form></body></html>

check.asp:

<%dimuserdimpwddimyzmuser=trim(request("txtname"))pwd=trim(request("txtpwd"))yzm=trim(request("txtyzm"))ifuser=""orpwd=""thenresponse.write"<script>alert('对不起,用户名和密码不能为空!');document.location.href='login.asp';</script>"response.endelseifuser="lc"thenifpwd="1234"thenifsession("verifycode")=yzmthenresponse.redirect""elseresponse.write"验证码输入有误!"endifelseresponse.write"密码输入有误!"endifelseresponse.write"用户名不存在!"endifendif%>

为了使程序简单易懂,以上实现没考虑数据库的连接。,以及验证码的刷新问题。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。