CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
山寨机中的战斗机! 程序优化工程师到底对IT界有没有贡献
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Web 开发 >  ASP

登录程序出错 请指点

楼主hequhecong(天之吻)2002-09-29 08:52:31 在 Web 开发 / ASP 提问

1.default.htm登录页面  
  <html>  
  <head>  
  <title>登录</title>  
  </head>  
  <body>  
  <form   name=form1   method="post"   action="login.asp">  
  姓名:<input   name="username"   type="text"   size=25>  
  密码:<input   name="userpass"   type="password"   size=25>  
  <input   type=submit   name=submit1   value="提交">  
  </form>  
  </body>  
  </html>  
  2.   login.asp登录程序  
  <%    
        dim   conn  
        dim   connstr  
        dim   db  
        db="datebase/students.mdb"  
        set   conn=server.createobject("adodb.connection")  
        connstr="driver={microsoft   access   driver   (*.mdb)};dbq="   &   server.mappath(db)  
        conn.open   connstr  
        dim   founderr  
        dim   errmsg  
        errmsg=""  
        founderr=false  
        set   rs=server.createobject("adodb.recordset")  
        username=trim(request("username"))  
        username=trim(request("userpass"))  
        if   username=""   or   userpass=""   then  
        errmsg=errmsg+"<br>"+"用户名和密码不能为空!"  
        founderr=true  
        end   if  
        rs.open   "select   *   from   student   where   username='"&username&"'"  
        if   rs.eof   then    
                  errmsg=errmsg+"br"+"你输入的用户不存在!"  
                  founderr=true  
        elseif   userpass=rs("userpass")   then  
                  session("username")=rs("username")  
        else    
                  errmsg=errmsg+"<br>"+"你输入的密码错误!"  
                  founderr=true  
        end   if  
        rs.close  
    %>  
    <%         if   founderr=true   then   '30  
                  response.write   errmsg  
                else    
                  response.write   "登录成功!"+"<br>"+"谢谢你的光临!"  
              end   if  
    %> 问题点数:100、回复次数:26Top

1 楼hequhecong(天之吻)回复于 2002-09-29 08:53:13 得分 0

出错在login.asp  
  line   20Top

2 楼abigfrog(千年精灵)(★JAVA★)回复于 2002-09-29 08:54:35 得分 0

rs.open   "select   *   from   student   where   username='"&username&"'",conn,1,1  
  Top

3 楼cshadow(heli)回复于 2002-09-29 08:57:31 得分 0

dim   sql  
  sql="select   *   from   student   where   username='"&username&"'"  
  rs.open.conn,1,3  
  Top

4 楼awaysrain(绝对零度)(既然选择了远方就要日夜前行)回复于 2002-09-29 08:57:41 得分 0

什么提示?Top

5 楼arclala(呱呱)回复于 2002-09-29 08:59:25 得分 0

别忘了后面的conn,1,1Top

6 楼xjbx()回复于 2002-09-29 09:00:17 得分 0

rs.open   "select   *   from   student   where   username='"&username&"'",conn,1,3Top

7 楼hequhecong(天之吻)回复于 2002-09-29 09:24:37 得分 0

我按照   abigfrog  
  修改之后确实可行  
  但是提示每次都是密码错误  
  这是什么原因Top

8 楼qimangxing(徐家庄的七芒星)回复于 2002-09-29 09:25:06 得分 0

cshadow(影子),好像有点错误吧:  
  dim   sql  
  sql="select   *   from   student   where   username='"&username&"'"  
  rs.open   sql,conn,1,3Top

9 楼abigfrog(千年精灵)(★JAVA★)回复于 2002-09-29 09:26:26 得分 0

username=trim(request("username"))  
  userpass=trim(request("userpass"))  
  Top

10 楼crater(火山口)回复于 2002-09-29 09:28:15 得分 0

当然得先连接数据库,才能取得数据集。  
  Top

11 楼hequhecong(天之吻)回复于 2002-09-29 09:29:40 得分 0

我早已经改过来了  
  但是还是同样的错误Top

12 楼hequhecong(天之吻)回复于 2002-09-29 09:30:26 得分 0

<%    
        dim   conn  
        dim   connstr  
        dim   db  
        db="datebase/students.mdb"  
        set   conn=server.createobject("adodb.connection")  
        connstr="driver={microsoft   access   driver   (*.mdb)};dbq="   &   server.mappath(db)  
        conn.open   connstr  
        dim   founderr  
        dim   errmsg  
        errmsg=""  
        founderr=false  
        set   rs=server.createobject("adodb.recordset")  
        username=trim(request("username"))  
        userpass=trim(request("userpass"))  
        if   username=""   or   userpass=""   then  
        errmsg=errmsg+"<br>"+"用户名和密码不能为空!"  
        founderr=true  
        end   if  
        rs.open   "select   *   from   student   where   username='"&username&"'",conn,1,3  
        if   rs.eof   then    
                  errmsg=errmsg+"<br>"+"你输入的用户不存在!"  
                  founderr=true  
        elseif   userpass=rs("userpass")   then  
                  session("username")=rs("username")  
        else    
                  errmsg=errmsg+"<br>"+"你输入的密码错误!"  
                  founderr=true  
        end   if  
        rs.close  
    %>  
    <%         if   founderr=true   then   '30  
                  response.write   errmsg  
                else    
                  response.write   "登录成功!"+"<br>"+"谢谢你的光临!"  
              end   if  
    %>Top

13 楼abigfrog(千年精灵)(★JAVA★)回复于 2002-09-29 09:32:39 得分 70

<%    
        dim   conn  
        dim   connstr  
        dim   db  
        db="datebase/students.mdb"  
        set   conn=server.createobject("adodb.connection")  
        connstr="driver={microsoft   access   driver   (*.mdb)};dbq="   &   server.mappath(db)  
        conn.open   connstr  
        dim   founderr  
        dim   errmsg  
        errmsg=""  
        founderr=false  
        set   rs=server.createobject("adodb.recordset")  
        username=trim(request("username"))  
        username=trim(request("userpass"))  
        if   username=""   or   userpass=""   then  
        errmsg=errmsg+"<br>"+"用户名和密码不能为空!"  
        founderr=true  
        end   if  
        rs.open   "select   *   from   student   where   username='"&username&"'",conn,1,1  
        if   rs.bof   and   rs.eof   then    
                  errmsg=errmsg+"br"+"你输入的用户不存在!"  
                  founderr=true  
        else    
                if     userpass=rs("userpass")   then  
                        session("username")=rs("username")  
                   
                else    
                        errmsg=errmsg+"<br>"+"你输入的密码错误!"  
                        founderr=true  
                end   if  
        end   if  
        rs.close  
        set   rs=nothing  
    %>  
    <%         if   founderr=true   then   '30  
                  response.write   errmsg  
                else    
                  response.write   "登录成功!"+"<br>"+"谢谢你的光临!"  
              end   if  
    %>  
  Top

14 楼abigfrog(千年精灵)(★JAVA★)回复于 2002-09-29 09:40:00 得分 0

if     userpass=rs("userpass")   then  
                        session("username")=rs("username")  
                        founderr=false  
  else    
                        errmsg=errmsg+"<br>"+"你输入的密码错误!"  
                        founderr=true  
  end   if  
   
  还是不行?不可能吧?没错误了!  
  Top

15 楼hequhecong(天之吻)回复于 2002-09-29 09:45:33 得分 0

还是不行  
  if   rs.bof   and   rs.eof   then    
  那个rs.bof是什么意思Top

16 楼abigfrog(千年精灵)(★JAVA★)回复于 2002-09-29 09:51:46 得分 0

给你一个我写的函数  
   
  function   check_login(user_name,user_pwd,table_user_name,table_user_pwd,table_name)  
  dbLink   "../database/library.mdb"  
  Dim   rs      
  on   error   resume   next  
  Set   rs=ConnDB.execute("select   "&table_user_name&"   from   "&table_name&"   where   "&table_user_name&"='"&user_name&"'")  
  if   err   then   response.Write(err.description)  
  if(rs.bof   and   rs.eof)   then    
  CleanUp(rs)  
  check_login=0  
  else  
  Set   rs=ConnDB.execute("select   "&table_user_pwd&"   from   "&table_name&"   where   "&table_user_pwd&"='"&user_pwd&"'")  
  if   not   (rs.bof   and   rs.eof)   then  
  check_login=1  
  else  
  check_login=0  
  end   if  
  CleanUp(rs)  
  end   if  
  dbClose()  
  end   function  
   
  使用举例:  
   
  if   check_login(""&request("user_name")&"",""&request("user_pwd")&"","user_name","user_pwd","users")=1   then  
  server.transfer("default.asp")  
  else  
  response.write("error!")  
  end   ifTop

17 楼hequhecong(天之吻)回复于 2002-09-29 10:00:24 得分 0

你这个肯定错误  
  Top

18 楼abigfrog(千年精灵)(★JAVA★)回复于 2002-09-29 10:01:49 得分 0

肯定错误?什么意思?我用的好好的!!Top

19 楼beini2001(苏秦)回复于 2002-09-29 10:43:58 得分 0

好象你没有对密码的正确与否进行判断  
   
  你再自己找找看  
   
  if   rs.eof   then    
                  errmsg=errmsg+"br"+"你输入的用户不存在!"  
                  founderr=true  
        elseif   userpass<>rs("userpass")   then  
                  errmsg=errmsg+"<br>"+"你输入的密码错误!"  
   
        else    
                  session("username")=rs("username")  
  end   if  
         
   
  Top

20 楼hequhecong(天之吻)回复于 2002-09-29 11:16:39 得分 0

我知道错误出在哪里了  
  我开始一直也认为程序没错  
  果然不出我所料  
  是出在数据库:user_pass   类型  
  不能为数字   应为   文本  
  Top

21 楼abigfrog(千年精灵)(★JAVA★)回复于 2002-09-29 11:27:20 得分 0

晕菜~~   @_@Top

22 楼abigfrog(千年精灵)(★JAVA★)回复于 2002-09-29 11:28:41 得分 0

晕菜~~   @_@Top

23 楼hequhecong(天之吻)回复于 2002-09-29 19:19:02 得分 0

是不是碰到过这种问题Top

24 楼abigfrog(千年精灵)(★JAVA★)回复于 2002-09-29 19:33:35 得分 0

从来没有...Top

25 楼zat1978(蓟)回复于 2002-09-29 19:42:18 得分 15

<%    
        dim   conn  
        dim   connstr  
        dim   db  
        db="datebase/students.mdb"  
        set   conn=server.createobject("adodb.connection")  
        connstr="driver={microsoft   access   driver   (*.mdb)};dbq="   &   server.mappath(db)  
        conn.open   connstr  
        dim   founderr  
        dim   errmsg  
        errmsg=""  
        founderr=false  
        set   rs=server.createobject("adodb.recordset")  
        username=trim(request("username"))  
        userpass=trim(request("userpass"))  
        if   username=""   or   userpass=""   then  
        errmsg=errmsg+"<br>"+"用户名和密码不能为空!"  
        founderr=true  
        end   if  
        rs.open   "select   *   from   student   where   username='"&username&"'",conn,1,3  
        if   rs.eof   then    
                  errmsg=errmsg+"<br>"+"你输入的用户不存在!"  
                  founderr=true  
        elseif   userpass=rs("userpass")   then  
                  session("username")=rs("username")  
  '这里少一个  
                  founderr=false   '这个如果不写就永远登陆不上,因为你前面已经把这个变量附值为true了  
        else    
                  errmsg=errmsg+"<br>"+"你输入的密码错误!"  
                  founderr=true  
        end   if  
        rs.close  
    %>  
    <%         if   founderr=true   then   '30  
                  response.write   errmsg  
                else    
                  response.write   "登录成功!"+"<br>"+"谢谢你的光临!"  
              end   if  
    %>  
  Top

26 楼zykj_2000(向MVP努力)回复于 2002-09-29 21:32:25 得分 15

我晕了,   你又没有说清楚,你要人们怎么猜你的数据字段类型啊Top

27 楼hequhecong(天之吻)回复于 2002-09-29 22:45:10 得分 0

我通过这个脚本可以看得出  
  其实要想成为高手  
  必须要有非常牢的基础  
  经验必须靠实践  
  多想   多做    
  高手必经之路!Top

相关问题

  • 应用程序运行出错,请高手指点!
  • 一段程序为什么出错,请指点
  • 网络小程序编译出错,请高手指点
  • 请您指点:程序连接时出错!!
  • 我的程序编译出错,谁能指点一下
  • MFC查询SQL Server表的程序linking出错,希望指点
  • 程序出错,请大家指点一下
  • 出学JAVA小程序,却出错,望高手指点
  • 一个应该说很简单的程序,怎么会出错!?指点一下
  • 我的程序怎么老是出现kerner32.dll出错,请高手指点!!!

关键词

得分解答快速导航

  • 帖主:hequhecong
  • abigfrog
  • zat1978
  • zykj_2000

相关链接

  • Web开发类图书

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo