您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 销售管理 > ASP网页登陆密码及用户名检测(VB+ACCESS)
ASP网页登陆密码及用户名检测(VB+ACCESS)1.建立一个access数据库保存,打开“使用表设计器创建表”详细如下:字段名称数据类型id自动编号username文本password文本2.login.asp文件内容如下:htmlheadtitle系统管理员登陆/titlemetahttp-equiv=Content-Typecontent=text/html;charset=gb2312scriptLanguage=javaScriptfunctionlogin_validate(){if(document.myform.username.value==){alert(Error:请输入帐号!);document.myform.username.focus();returnfalse;}if(document.myform.password.value==){alert(Error:请输入密码!);document.myform.password.focus();returnfalse;}returntrue;}/scriptstyletype=text/css!--body,td{font-size:12px;}--/style/headbodyp/pformaction=checkmima.aspmethod=postNAME=myformid=myformonSubmit=returnlogin_validate();tablewidth=250border=0align=centercellpadding=5cellspacing=1style=border:1px#ccccccsolid;trtdheight=30bgcolor=#eeeeeealign=center∷管理员登陆∷/td/trtrtdalign=center用户名:inputname=Usernametabindex=1type=textid=username/td/trtrtdalign=center密码:inputname=Passwordtabindex=2type=passwordid=password/td/trtrtdalign=centerinputtype=submitname=Submitvalue=登陆tabindex=3inputtype=resetname=Submit2value=重置tabindex=4/td/tr/table/form/body/html3.checkmima.asp文件内容如下:%db=数据库路径/数据库名称.mdbSetconn=Server.CreateObject(ADODB.Connection)connstr=Provider=Microsoft.Jet.OLEDB.4.0;DataSource=&Server.MapPath(&db&)'connstr=DBQ=+server.mappath(&db&)+;DefaultDir=;DRIVER={MicrosoftAccessDriver(*.mdb)};conn.Openconnstr%%dimsqldimrsdimusernamedimpasswordusername=replace(trim(request(username)),',)password=replace(trim(Request(password)),',)sql=selectusername,password,flagfromzhucewherepassword='&password&'andusername='&username&'setrs=conn.execute(sql)ifnot(rs.bofandrs.eof)thenifpassword=rs(1)thensession(admin)=rs(0)session(flag)=rs(2)Response.RedirectDefault.asp//登陆成功后要跳转到的页面elsecallErrorendifelsecallError()endifsubError()Response.Writescriptlanguage=javascriptResponse.Writealert(登陆失败!帐号或密码错误!);Response.Writehistory.back(-1);Response.Write/scriptendsubrs.closeconn.closesetrs=nothingsetconn=nothing%
本文标题:ASP网页登陆密码及用户名检测(VB+ACCESS)
链接地址:https://www.777doc.com/doc-2898880 .html