| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1616 人关注过本帖
标题:ASP链接数据库问题!!!
只看楼主 加入收藏
无忧当当
Rank: 1
等 级:新手上路
帖 子:40
专家分:0
注 册:2008-7-9
收藏
得分:0 
乱了,你还是帮我再检查一下代码吧
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="../Connections/hd.asp" -->
<%
' *** Validate request to log in to this site.
MM_LoginAction = Request.ServerVariables("URL")
If Request.QueryString <> "" Then MM_LoginAction = MM_LoginAction + "?" + Server.HTMLEncode(Request.QueryString)
MM_valUsername = CStr(Request.Form("name"))
If MM_valUsername <> "" Then
  Dim MM_fldUserAuthorization
  Dim MM_redirectLoginSuccess
  Dim MM_redirectLoginFailed
  Dim MM_loginSQL
  Dim MM_rsUser
  Dim MM_rsUser_cmd
  
  MM_fldUserAuthorization = ""
  MM_redirectLoginSuccess = "index.asp"
  MM_redirectLoginFailed = "loginfailse.asp"

  MM_loginSQL = "SELECT name, password"
  If MM_fldUserAuthorization <> "" Then MM_loginSQL = MM_loginSQL & "," & MM_fldUserAuthorization
  MM_loginSQL = MM_loginSQL & " FROM zhanghao WHERE name = ? AND password = ?"
  Set MM_rsUser_cmd = Server.CreateObject (")
  MM_rsUser_cmd.ActiveConnection = MM_hd_STRING
  MM_rsUser_ = MM_loginSQL
  MM_rsUser_cmd.Parameters.Append MM_rsUser_cmd.CreateParameter("param1", 200, 1, 10, MM_valUsername) ' adVarChar
  MM_rsUser_cmd.Parameters.Append MM_rsUser_cmd.CreateParameter("param2", 200, 1, 20, Request.Form("password")) ' adVarChar
  MM_rsUser_cmd.Prepared = true
  Set MM_rsUser = MM_rsUser_cmd.Execute

  If Not MM_rsUser.EOF Or Not MM_rsUser.BOF Then
    ' username and password match - this is a valid user
    Session("MM_Username") = MM_valUsername
    If (MM_fldUserAuthorization <> "") Then
      Session("MM_UserAuthorization") = CStr(MM_rsUser.Fields.Item(MM_fldUserAuthorization).Value)
    Else
      Session("MM_UserAuthorization") = ""
    End If
    if CStr(Request.QueryString("accessdenied")) <> "" And false Then
      MM_redirectLoginSuccess = Request.QueryString("accessdenied")
    End If
    MM_rsUser.Close
    Response.Redirect(MM_redirectLoginSuccess)
  End If
  MM_rsUser.Close
  Response.Redirect(MM_redirectLoginFailed)
End If
%>
<%
' *** Validate request to log in to this site.
MM_LoginAction = Request.ServerVariables("URL")
If Request.QueryString <> "" Then MM_LoginAction = MM_LoginAction + "?" + Server.HTMLEncode(Request.QueryString)
MM_valUsername = CStr(Request.Form("name"))
If MM_valUsername <> "" Then
  Dim MM_fldUserAuthorization
  Dim MM_redirectLoginSuccess
  Dim MM_redirectLoginFailed
  Dim MM_loginSQL
  Dim MM_rsUser
  dim name,password
  username=Trim(request("username"))
password=Trim(repuest("password"))
  Dim MM_rsUser_cmd
  MM_fldUserAuthorization = ""
  MM_redirectLoginSuccess = "index.asp"
  MM_redirectLoginFailed = "loginfailse.asp"

  MM_loginSQL = "SELECT name, password"
  If MM_fldUserAuthorization <> "" Then MM_loginSQL = MM_loginSQL & "," & MM_fldUserAuthorization
  MM_loginSQL = MM_loginSQL & " FROM zhanghao WHERE name = ? AND password = ?"
  Set MM_rsUser_cmd = Server.CreateObject (")
  MM_rsUser_cmd.ActiveConnection = MM_hd_STRING
  MM_rsUser_ = MM_loginSQL
  MM_rsUser_cmd.Parameters.Append MM_rsUser_cmd.CreateParameter("param1", 200, 1, 10, MM_valUsername) ' adVarChar
  MM_rsUser_cmd.Parameters.Append MM_rsUser_cmd.CreateParameter("param2", 200, 1, 20, Request.Form("password")) ' adVarChar
  MM_rsUser_cmd.Prepared = true
  Set MM_rsUser = MM_rsUser_cmd.Execute

  If Not MM_rsUser.EOF Or Not MM_rsUser.BOF Then
    ' username and password match - this is a valid user
    Session("MM_Username") = MM_valUsername
    If (MM_fldUserAuthorization <> "") Then
      Session("MM_UserAuthorization") = CStr(MM_rsUser.Fields.Item(MM_fldUserAuthorization).Value)
    Else
      Session("MM_UserAuthorization") = ""
    End If
    if CStr(Request.QueryString("accessdenied")) <> "" And false Then
      MM_redirectLoginSuccess = Request.QueryString("accessdenied")
    End If
    MM_rsUser.Close
    Response.Redirect(MM_redirectLoginSuccess)
  End If
  MM_rsUser.Close
  Response.Redirect(MM_redirectLoginFailed)
End If
%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>登入专区</title>
<style type="text/css">
<!--
.STYLE3 {font-size: 9pt; font-family: "宋体"; }
.STYLE4 {
    color: #FF0000;
    font-weight: bold;
}
.url_menu {
    font-family: "宋体";
    font-size: 9pt;
    color: #000000;
    text-decoration: none;
}
-->
</style>
<link href="main.css" rel="stylesheet" type="text/css" />
<link href="../main.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
<!--
function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    document.MM_returnValue = (errors == '');
} }
//-->
</script>
</head>

<body>
<table width="200" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="845" height="134" colspan="9"><img src="../images/logo.png" alt="" name="logo" width="845" height="134" id="logo" /></td>
  </tr>
  <tr align="center" valign="middle" bordercolor="#C4B9AA" bgcolor="#C4B9AA">
    <td height="24"><span class="STYLE3"><a href="index.html" class="url_menu">首页</a></span></td>
    <td><span class="STYLE3">班委会</span></td>
    <td><span class="STYLE3">团支部</span></td>
    <td><span class="STYLE3">互动专区</span></td>
    <td><span class="STYLE3"><a href="wenjian/list.asp" class="url_menu">班级文件</a></span></td>
    <td><span class="STYLE3"><a href="gonggao/list.asp" class="url_menu">班级公告</a></span></td>
    <td><span class="STYLE3">友邻班级</span></td>
    <td><span class="STYLE3">教师专栏</span></td>
    <td><span class="STYLE3">关于我们</span></td>
  </tr>
  <tr align="center" valign="middle">
    <td height="24" colspan="9" align="left" class="STYLE3">当前位置 &gt;&gt; 互动专区 &gt;&gt; <span class="STYLE4">登入专区</span></td>
  </tr>
</table>
<table width="845" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="845" class="STYLE2">&nbsp;</td>
  </tr>
  <tr>
    <td class="STYLE2"><strong>只有班级成员和老师才能登入互动专区</strong></td>
  </tr>
  <tr>
    <td class="STYLE2">&nbsp;</td>
  </tr>
  <tr>
    <td class="STYLE2">&nbsp;</td>
  </tr>
</table>
<form ACTION="<%=MM_LoginAction%>" method="POST" name="form1" id="form1">
  <table width="845" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td width="336" align="right" class="STYLE2">姓名:</td>
      <td width="509" class="STYLE2"><label>
        <input name="name" type="text" id="name" />
      </label></td>
    </tr>
    <tr>
      <td align="right" class="STYLE2">口令:</td>
      <td class="STYLE2"><label>
<input name="password" type="password" id="password" size="22" />
忘记口令?</label></td>
    </tr>
    <tr>
      <td class="STYLE2">&nbsp;</td>
      <td class="STYLE2">&nbsp;</td>
    </tr>
    <tr>
      <td colspan="2" class="STYLE2"><label>                          
          <input name="button" type="submit" id="button" onclick="MM_validateForm('name','','R','password','','R');return document.MM_returnValue" value="登入专区" />
      </label>
        <label>
        <input type="reset" name="button2" id="button2" value="重新填写" />
        </label></td>
    </tr>
  </table>
</form>
<p>&nbsp;</p>
<p>&nbsp;</p>
</body>
</html>
2008-07-09 17:26
towering
Rank: 7Rank: 7Rank: 7
等 级:黑侠
威 望:1
帖 子:261
专家分:507
注 册:2007-10-9
收藏
得分:0 
试试这个吧:

login.rar (2.68 KB)
2008-07-09 17:39
快速回复:ASP链接数据库问题!!!
数据加载中...
 
   



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

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