| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1090 人关注过本帖
标题:asp后台问题
只看楼主 加入收藏
天龙
Rank: 1
等 级:新手上路
帖 子:20
专家分:0
注 册:2008-3-7
收藏
 问题点数:0 回复次数:9 
asp后台问题
opendb.asp中的代码
<%
session.abandon
'Server.ScriptTimeOut=500
function opendb(DBPath,sessionname,dbsort)
dim conn,StrCnn
if not isobject(session(sessionname)) then
Set conn=Server.CreateObject("ADODB.Connection")
DBPath1=server.MapPath("/oa/office/database/myoffice.mdb")
conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & DBPath1
'StrCnn = "Driver={SQL Server};Server=220.113.41.48;UID=vip8848;PWD=s8wfsqlde3acvip;Database=vip88481"
'StrCnn = "Driver={SQL Server};Server=192.168.8.198;UID=sa ;PWD=;Database=vip88481"

'conn.Open StrCnn
response.write DBPath1
response.end

set session(sessionname)=conn
end if
set opendb=session(sessionname)
end function
%>
index.asp中的代码
<!--#include file="office/asp/sqlstr.asp"-->
<!--#include file="office/asp/opendb.asp"-->

<%
'登录
username=request("username")
password=request("password")
if username<>"" and password<>"" then
'打开数据库查找是否有此用户
set conn=opendb("oabusy","conn","accessdsn")
set rs=server.createobject("adodb.recordset")
sql="select * from userinf where username=" & sqlstr(username) & " and password=" & sqlstr(password) & " and forbid='no'"
rs.open sql,conn,1
'如果有此用户就进入系统
if not rs.eof and not rs.bof then

response.cookies("oabusyname")=rs("name")
response.cookies("oabusyusername")=rs("username")
response.cookies("oabusyuserdept")=rs("userdept")
response.cookies("oabusyuserlevel")=rs("userlevel")

response.cookies("cook_allow_see_all_workrep")=rs("allow_see_all_workrep")
response.cookies("cook_allow_see_dept_workrep")=rs("allow_see_dept_workrep")

response.cookies("cook_allow_control_dept_user")=rs("allow_control_dept_user")
response.cookies("cook_allow_control_all_user")=rs("allow_control_all_user")

response.cookies("cook_allow_send_note")=rs("allow_send_note")
response.cookies("cook_allow_control_note")=rs("allow_control_note")

response.cookies("cook_allow_control_file")=rs("allow_control_file")

response.cookies("cook_allow_control_level")=rs("allow_control_level")

'response.cookies("cook_allow_see_all_personinf")=rs("allow_see_all_personinf")
'response.cookies("cook_allow_see_dept_personinf")=rs("allow_see_dept_personinf")
'response.cookies("cook_allow_edit_all_jobchanginf")=rs("allow_edit_all_jobchanginf")
'response.cookies("cook_allow_edit_dept_jobchanginf")=rs("allow_edit_dept_jobchanginf")
'response.cookies("cook_allow_edit_all_rewpuninf")=rs("allow_edit_all_rewpuninf")
'response.cookies("cook_allow_edit_dept_rewpuninf")=rs("allow_edit_dept_rewpuninf")
'response.cookies("cook_allow_edit_all_checkinf")=rs("allow_edit_all_checkinf")
'response.cookies("cook_allow_edit_dept_checkin")=rs("allow_edit_dept_checkinf")


response.redirect  "office/gensystem.asp"
end if
end if
%>
<HTML><HEAD><TITLE>深圳市一之路科技有限公司网络办公平台</TITLE>
<META content="text/html; charset=GB2312" http-equiv=Content-Type><LINK
href="images/style.css" rel=STYLESHEET type=text/css>
<SCRIPT language=Javascript>
                function ConfirmAction(message,url)
                {if(confirm(message)) location = url    ;}
                </SCRIPT>

<META content="MSHTML 5.00.3103.1000" name=GENERATOR></HEAD>
<BODY aLink=#336699 background=images/logon.htm bgColor=#b9b9b9
link=#000000 text=black vLink=#333333>
<STYLE type=text/css>.fs {
    COLOR: #ffffff; FONT-FAMILY: "宋体", "黑体", "楷体_GB2312", "隶书"; FONT-SIZE: 9pt
}
.inputline {
    BACKGROUND-IMAGE: url(images/bg.gif); BORDER-BOTTOM: #ffffff 1px solid; BORDER-LEFT: #ffffff 1px solid; BORDER-RIGHT: #ffffff 1px solid; BORDER-TOP: #ffffff 1px solid; COLOR: #5a5a5a; FONT-FAMILY: "宋体", "黑体", "楷体_GB2312", "隶书"; FONT-SIZE: 9pt
}
.btnbg {
    BACKGROUND-IMAGE: url(images/login.gif); BACKGROUND-REPEAT: no-repeat; BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; BORDER-RIGHT: 0px; BORDER-TOP: 0px; CURSOR: hand; FONT-FAMILY: "宋体", "黑体", "楷体_GB2312", "隶书"; FONT-SIZE: 18px; MARGIN: 0px; PADDING-BOTTOM: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px
}
.btnreset {
    BACKGROUND-IMAGE: url(images/reset.gif); BACKGROUND-REPEAT: no-repeat; BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; BORDER-RIGHT: 0px; BORDER-TOP: 0px; CURSOR: hand; FONT-FAMILY: "宋体", "黑体", "楷体_GB2312", "隶书"; FONT-SIZE: 18px
}
BODY {
    MARGIN: 0px
}
</STYLE>

<TABLE background=images/main.jpg border=0 cellPadding=0 cellSpacing=0
height=420 width=780>
  <TBODY>
  <TR>
    <TD>
      <DIV id=login
      style="HEIGHT: 113px; LEFT: 272px; POSITION: absolute; TOP: 349px; WIDTH: 208px; Z-INDEX: 2">
      <TABLE border=0 cellPadding=0 cellSpacing=0 class=fs height=85
      width="100%">
        <FORM action=index.asp method=post name=Form1
        onsubmit="CheckValue(this);return false">

        <TR>
          <TD width="37%">
            <DIV align=right><FONT color=black>用户名:</FONT></DIV></TD>
          <TD width="63%">
                <INPUT class=inputline name=Block size=22>
                 </TD></TR>
        <TR>
          <TD width="37%">
            <DIV align=right><FONT color=black>密&nbsp;&nbsp;码:</FONT></DIV></TD>
          <TD width=63>
                <INPUT class=inputline name=Password size=22
            type=password>
                 </TD></TR>
        <TR>
          <TD colSpan=2>
            <DIV align=center>
            <TABLE background="" border=0 cellPadding=0 cellSpacing=0>
              <TBODY>
              <TR>
                <TD>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
                <TD>
                  <DIV align=right><INPUT class=btnbg name=Submit type=submit value="     ">
                  </DIV></TD>
                <TD>
                  <DIV align=left><INPUT class=btnreset name=reset type=reset value="     ">
                  </DIV></TD></TR></TBODY></TABLE></DIV></TD></TR><INPUT name=UserName
        type=hidden> </FORM>
          </TABLE></DIV></TD></TR></TBODY></TABLE>
<SCRIPT language=JavaScript>
                if(document.forms[0] != null)    {
                    if(document.forms[0].elements[0] != null) {
                        if(document.forms[0].elements[0].type != 'hidden')
                            document.forms[0].elements[0].focus();
                    }
                }
            </SCRIPT>
<!-- Copyright 2001, HotOA Inc. All Rights Reserved. -->
<SCRIPT language=JavaScript>
    function CheckValue(thisform)
    {

        thisform.UserName.value = thisform.Block.value;
        thisform.Block.value = "";

        if (thisform.UserName.value.length == 0){
        alert ('请输入用户名。');
        }

        else if (thisform.Password.value.length == 0){
        alert ('请输入密码。');
        }

        else {

        if (document.Form1.Password.value.length != 0 && document.Form1.UserName.value.length != 0)
            thisform.submit();
        }
    }
    </SCRIPT>

<SCRIPT language=JAVASCRIPT>
    if(navigator.appName == "Netscape" &&
          parseFloat(navigator.appVersion.substring(0,4)) >= 4 ) {
               document.captureEvents(Event.KEYPRESS);
            document.onkeypress = CheckKey;

            function CheckKey(evt) {
                if (evt.which == 13) {
                    CheckValue(document.Form1);
                    return false;
                   }
                else {
                    return evt.which;
                }
            }
    }
    </SCRIPT>
</BODY></HTML>
当点index.asp中的登陆后会显示数据库的路径,没有转到想要转到的网页 我是个编程新手 请大家帮帮忙!!
搜索更多相关主题的帖子: SQL 后台 Microsoft asp 
2008-03-07 15:42
hmhz
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:30
帖 子:1890
专家分:503
注 册:2006-12-17
收藏
得分:0 
response.write DBPath1
改成
response.redirect "index.asp"
2008-03-07 15:55
天龙
Rank: 1
等 级:新手上路
帖 子:20
专家分:0
注 册:2008-3-7
收藏
得分:0 
还不行呢
我刚刚试了一下,在index.asp中登陆,又返回到了index.asp界面了
2008-03-07 16:04
tianyu123
Rank: 1
等 级:新手上路
威 望:2
帖 子:576
专家分:0
注 册:2007-8-26
收藏
得分:0 
去掉opendb.asp代码中的

'conn.Open StrCnn
response.write DBPath1
response.end '这句去掉

改变一切,须从改变观念开始!
2008-03-07 16:47
天龙
Rank: 1
等 级:新手上路
帖 子:20
专家分:0
注 册:2008-3-7
收藏
得分:0 
不对啊
还是停留在index.asp页面上.不知道哪里有错
2008-03-07 18:48
天龙
Rank: 1
等 级:新手上路
帖 子:20
专家分:0
注 册:2008-3-7
收藏
得分:0 
有没有高手帮帮忙啊
我的数据库,里面的表,有些没有数据,是不是这个原因呢?
2008-03-08 10:33
天龙
Rank: 1
等 级:新手上路
帖 子:20
专家分:0
注 册:2008-3-7
收藏
得分:0 
高手指点啊,谢谢了
高手指点啊,谢谢了 
2008-03-09 22:29
ycb1689
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2006-8-28
收藏
得分:0 
<%
'登录
username=request("username")
password=request("password")
if username<>"" and password<>"" then
'打开数据库查找是否有此用户
response.write"<script>"
response.write"alert('登录成功!');"
response.write"location.href='my.asp';"
response.write"</script>"
response.end
end if
%>
<HTML><HEAD><TITLE>深圳市一之路科技有限公司网络办公平台</TITLE>
<META content="text/html; charset=GB2312" http-equiv=Content-Type><LINK
href="images/style.css" rel=STYLESHEET type=text/css>
<SCRIPT language=Javascript>
                function ConfirmAction(message,url)
                {if(confirm(message)) location = url    ;}
                </SCRIPT>

我这个测试过了可以用

[[it] 本帖最后由 ycb1689 于 2008-3-10 08:53 编辑 [/it]]
2008-03-10 08:52
天龙
Rank: 1
等 级:新手上路
帖 子:20
专家分:0
注 册:2008-3-7
收藏
得分:0 
非常感谢好心人
不过,我试过,但是没有判断数据库是否有此用户,就登陆成功了,请楼上的详细指点,小第在此谢谢了.
2008-03-10 09:57
a48567653
Rank: 1
等 级:新手上路
帖 子:45
专家分:0
注 册:2008-2-16
收藏
得分:0 
他本来就没给你判断,还有
 <FORM action=index.asp method=post name=Form1
        onsubmit="CheckValue(this);return false">
这句不是还在本页面没动么?
action=index.asp?+"传的参数"
这样大概可以了
2008-03-10 11:22
快速回复:asp后台问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.041288 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved