注册 登录
编程论坛 ASP技术论坛

asp 不能连进数据库

撒布拉斯 发布于 2011-03-23 11:26, 305 次点击
<!--#include file="con_db.asp" -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>网站后台管理</title>
<style type="text/css">
<!--
.STYLE1 {color: #FF0000}
-->
</style>
</head>

<body background="../image/forgetpw/password.jpg">
<div><form action="login.asp" method="post" onClick="">
  <center>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <table width="385" height="102" border="0" cellpadding="0" cellspacing="0"  bgcolor="#CCCCCC">
        <tr>
                <td width="110"><span class="STYLE1">登录界面</span></td>
                <td width="275">&nbsp;</td>
        </tr>
        <tr>
                <td><span class="STYLE1">用户:</span></td>
                <td><input type="text" name="UserName"></td>
        </tr>
        <tr>
                <td><span class="STYLE1">密码:</span></td>
                <td><input type="password" name="pwd">
                </td>
        </tr>
        <tr>
                <td><span class="STYLE1">权限:</span></td>
                <td><input name="radiobutton" type="radio" value="radiobutton" checked>
                        管理员
                                <input type="radio" name="radiobutton" value="radiobutton">
                                工作人员</td>
        </tr>
    </table>
      <input type="reset" name="Submit2" value="重置">   
      <input type="submit" name="Submit" value="提交">
  </center>
</form></div>
</body>
</html>

<%
  UserName=Trim(Request("UserName"))
  pwd=Trim(Request("pwd"))
  if user<>"" and pwd<>"" then
  Set LoginRS = Server.CreateObject("ADODB.RecordSet")
  SqlStr = "select * from admin where name='" & UserName & "'"
  LoginRS.Open SqlStr,Conn,1,3
  If LoginRS.EOF AND LoginRS.BOF Then
        response.write"<script language=JavaScript>alert('登录失败:\n\n您输入了错误的帐号,请再次输入!');"   
        response.write"this.location.href='Login.asp';</script>"
        Response.End
  Else
    IF LoginRS("PassWord")=pwd THEN
       IF Cint(LoginRS("Locked"))=1 Then
            response.write"<script language=JavaScript>alert('登录失败:\n\n您的账号已被管理员锁定,请与您的系统管理员联系!');"
            response.write"this.location.href='Login.asp';</script>"
              Response.End
       else
            LoginRS("LastTime")=Now()
            LoginRS("LastLoginIP")=userip
            LoginRS("num")=LoginRS("num")+1
            LoginRS.UpDate
            
            Response.Cookies("job_admin_Name")=LoginRS("admin")
            Response.Cookies("job_admin_PassWord")=LoginRS("PassWord")
            Response.Cookies("job_admin_flag")=LoginRS("flag")
            
            Response.Cookies("job_admin_Name").expires=(now()+1/24)
            Response.Cookies("job_admin_PassWord").expires=(now()+1/24)
            Response.Cookies("job_admin_flag").expires=(now()+1/24)
            
            Response.Redirect("Admin_Index.asp")
            Response.end
            End IF   
    else
         response.write"<script language=JavaScript>alert('登录失败:\n\n您的密码错误,请您重新输入!');"
        response.write"this.location.href='Login.asp';</script>"
        Response.End   
     end if
   end if
  else
   response.write"<script language=JavaScript>alert('登录失败:\n\n用户密码不能为空,请您重新输入!');"
   Response.End
  end if   
%>
程序代码:
<!--#include file="con_db.asp" -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>网站后台管理</title>
<style type="text/css">
<!--
.STYLE1
{color: #FF0000}
-->
</style>
</head>

<body background="../image/forgetpw/password.jpg">
<div><form action="login.asp" method="post" onClick="">
  <center>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <table width="385" height="102" border="0" cellpadding="0" cellspacing="0"  bgcolor="#CCCCCC">
        <tr>
                <td width="110"><span class="STYLE1">登录界面</span></td>
                <td width="275">&nbsp;</td>
        </tr>
        <tr>
                <td><span class="STYLE1">用户:</span></td>
                <td><input type="text" name="UserName"></td>
        </tr>
        <tr>
                <td><span class="STYLE1">密码:</span></td>
                <td><input type="password" name="pwd">
                </td>
        </tr>
        <tr>
                <td><span class="STYLE1">权限:</span></td>
                <td><input name="radiobutton" type="radio" value="radiobutton" checked>
                        管理员
                                <input type="radio" name="radiobutton" value="radiobutton">
                                工作人员</td>
        </tr>
    </table>
      <input type="reset" name="Submit2" value="重置">   
      <input type="submit" name="Submit" value="提交">
  </center>
</form></div>
</body>
</html>

<%
  UserName
=Trim(Request("UserName"))
  pwd
=Trim(Request("pwd"))
  
if user<>"" and pwd<>"" then
  
Set LoginRS = Server.CreateObject("ADODB.RecordSet")
  SqlStr
= "select * from admin where name='" & UserName & "'"
  LoginRS.Open SqlStr,Conn,
1,3
  
If LoginRS.EOF AND LoginRS.BOF Then
        response.write
"<script language=JavaScript>alert('登录失败:\n\n您输入了错误的帐号,请再次输入!');"   
        response.write
"this.location.href='Login.asp';</script>"
        Response.End
  
Else
   
IF LoginRS("PassWord")=pwd THEN
      
IF Cint(LoginRS("Locked"))=1 Then
            response.write
"<script language=JavaScript>alert('登录失败:\n\n您的账号已被管理员锁定,请与您的系统管理员联系!');"
            response.write
"this.location.href='Login.asp';</script>"
              Response.End
      
else
            LoginRS(
"LastTime")=Now()
            LoginRS(
"LastLoginIP")=userip
            LoginRS(
"num")=LoginRS("num")+1
            LoginRS.UpDate
           
            Response.Cookies(
"job_admin_Name")=LoginRS("admin")
            Response.Cookies(
"job_admin_PassWord")=LoginRS("PassWord")
            Response.Cookies(
"job_admin_flag")=LoginRS("flag")
           
            Response.Cookies(
"job_admin_Name").expires=(now()+1/24)
            Response.Cookies(
"job_admin_PassWord").expires=(now()+1/24)
            Response.Cookies(
"job_admin_flag").expires=(now()+1/24)
           
            Response.Redirect(
"Admin_Index.asp")
            Response.end
            
End IF   
   
else
         response.write
"<script language=JavaScript>alert('登录失败:\n\n您的密码错误,请您重新输入!');"
        response.write
"this.location.href='Login.asp';</script>"
        Response.End   
     
end if
   
end if
  
else
   response.write
"<script language=JavaScript>alert('登录失败:\n\n用户密码不能为空,请您重新输入!');"
   Response.End
  
end if   
%>















































1 回复
#2
dzt00012011-03-23 12:41
你要问的话,请先注明错误代码和提示,是哪一行错误。
你这样直接上一大堆代码,没人能帮你的。
1