ahuajjjj 2023-05-30 23:30 采纳率: 50%
浏览 19

提问sqlsever dw

img


我想请问基于sqlsever数据库和dw,思考二的当密码格式错误出现的额外文本框如何实现?数据库期终课c设计

![img](

![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/30088306458612.png "#lefthttps://img-mid.csdnimg.cn/release/static/image/mid/ask/218596064586117.png "#left")
")

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="Connections/conn2.asp" -->
<%
Dim MM_editAction
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
  MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If

' boolean to abort record edit
Dim MM_abortEdit
MM_abortEdit = false
%>
<%
If (CStr(Request("MM_insert")) = "form1") Then
  If (Not MM_abortEdit) Then
    ' execute the insert
    Dim MM_editCmd

    Set MM_editCmd = Server.CreateObject ("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_conn2_STRING
    MM_editCmd.CommandText = "INSERT INTO dbo.login_user (username, psw) VALUES (?, ?)" 
    MM_editCmd.Prepared = true
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 201, 1, 50, Request.Form("t1")) ' adLongVarChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 201, 1, 50, Request.Form("t2")) ' adLongVarChar
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close

    ' append the query string to the redirect URL
    Dim MM_editRedirectUrl
    MM_editRedirectUrl = "index_student.asp"
    If (Request.QueryString <> "") Then
      If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then
        MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
      Else
        MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
      End If
    End If
    Response.Redirect(MM_editRedirectUrl)
  End If
End If
%>
<%
Dim rs
Dim rs_cmd
Dim rs_numRows

Set rs_cmd = Server.CreateObject ("ADODB.Command")
rs_cmd.ActiveConnection = MM_conn2_STRING
rs_cmd.CommandText = "SELECT * FROM dbo.login_user" 
rs_cmd.Prepared = true

Set rs = rs_cmd.Execute
rs_numRows = 0
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
.indexfont {
    color: #FFF;
    font-size: 24px;
    text-align: center;
    font-weight: bold;
}
.indextablefont {
    color: #090;
}
#form1 table tr td {
    font-size: x-small;
}
</style>
</head>

<body>
<table width="60%" border="1" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td bgcolor="#0000FF" class="indexfont">::新用户注册::</td>
  </tr>
  <tr>
    <td height="145"><form id="form1" name="form1" method="POST" action="<%=MM_editAction%>">
      <table width="60%" border="0" align="center">
        <tr>
          <td width="36%" class="indextablefont">Username:</td>
          <td width="64%"><input type="text" name="t1" id="t1" /></td>
        </tr>
        <tr>
          <td class="indextablefont">Password:</td>
          <td><input type="text" name="t2" id="t2" />
            (密码要求为6-10位)</td>
        </tr>
        <tr>
          <td class="indextablefont">验证码:</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td><input name="button" type="submit" class="indextablefont" id="button" value="注册" /></td>
        </tr>
      </table>
      <input type="hidden" name="MM_insert" value="form1" />
    </form></td>
  </tr>
  <tr>
    <td bgcolor="#0033FF" class="indexfont">::版权所有::</td>
  </tr>
  <tr>
    <td bgcolor="#0033FF" class="indexfont">&nbsp;</td>
  </tr>
</table>
</body>
</html>
<%
rs.Close()
Set rs = Nothing
%>



<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="Connections/conn2.asp" -->
<%
Dim rs
Dim rs_cmd
Dim rs_numRows

Set rs_cmd = Server.CreateObject ("ADODB.Command")
rs_cmd.ActiveConnection = MM_conn2_STRING
rs_cmd.CommandText = "SELECT * FROM dbo.login_user" 
rs_cmd.Prepared = true

Set rs = rs_cmd.Execute
rs_numRows = 0
%>
<%
' *** 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 = "student_list.asp"
  MM_redirectLoginFailed = "index_student.asp?err=用户名或密码错误"

  MM_loginSQL = "SELECT username, psw"
  If MM_fldUserAuthorization <> "" Then MM_loginSQL = MM_loginSQL & "," & MM_fldUserAuthorization
  MM_loginSQL = MM_loginSQL & " FROM dbo.login_user WHERE username = ? AND psw = ?"
  Set MM_rsUser_cmd = Server.CreateObject ("ADODB.Command")
  MM_rsUser_cmd.ActiveConnection = MM_conn2_STRING
  MM_rsUser_cmd.CommandText = MM_loginSQL
  MM_rsUser_cmd.Parameters.Append MM_rsUser_cmd.CreateParameter("param1", 200, 1, 50, MM_valUsername) ' adVarChar
  MM_rsUser_cmd.Parameters.Append MM_rsUser_cmd.CreateParameter("param2", 200, 1, 50, Request.Form("psw")) ' 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 true 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.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
.indexfont {
    color: #FFF;
    font-size: 24px;
    text-align: center;
    font-weight: bold;
}
.indextablefont {
    color: #090;
}
</style>
<script type="text/javascript">
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
</script>
</head>

<body>
<table width="60%" border="1" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td bgcolor="#0099FF" class="indexfont">::理工教学管理系统学生端登录::</td>
  </tr>
  <tr>
    <td height="145"><form ACTION="<%=MM_LoginAction%>" METHOD="POST" id="user_login" name="user_login">
      <table width="60%" border="0" align="center">
        <tr>
          <td width="36%" class="indextablefont">Username:</td>
          <td width="64%"><input type="text" name="name" id="name" /></td>
        </tr>
        <tr>
          <td class="indextablefont">Password:</td>
          <td><input type="password" name="psw" id="psw" /></td>
        </tr>
        <tr>
          <td class="indextablefont">验证码:</td>
          <td><input type="text" name="name2" id="name2" /></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td><input name="button" type="submit" id="button" value="登录" />
            <input name="button2" type="button" id="button2" onclick="MM_openBrWindow('index_student_zhuce.asp','','')" value="注册" /></td>
        </tr>
      </table>
    </form></td>
  </tr>
  <tr>
    <td bgcolor="#00CCFF" class="indexfont">::48号版权所有::</td>
  </tr>
  <tr>
    <td bgcolor="#0099FF" class="indexfont"><%= Request.QueryString("err") %></td>
  </tr>
</table> 
</body>
</html>
<%
rs.Close()
Set rs = Nothing
%>



  • 写回答

1条回答 默认 最新

  • 于扶摇 2023-05-31 15:34
    关注

    要实现这一点,你可以使用SQL Server的存储过程(Stored Procedure)和DW的宏(Macro)来完成。具体步骤如下:

    在SQL Server数据库中创建一个存储过程,用于创建和修改用户账户,包括设置密码等操作。在这个存储过程中,你可以检查输入的密码是否符合规定的格式,如果不符合就返回一个错误信息。
    在DW中创建一个宏,用于在用户修改密码时调用存储过程。在宏中,你可以调用存储过程,将新密码作为参数传递给它。如果存储过程返回错误信息,那么在DW中就可以显示额外的文本框,提示用户密码格式不正确。

    评论

报告相同问题?

问题事件

  • 修改了问题 5月30日
  • 创建了问题 5月30日

悬赏问题

  • ¥15 如何使用simulink建立一个永磁同步直线电机模型?
  • ¥30 天体光谱图的的绘制并得到星表
  • ¥15 PointNet++的onnx模型只能使用一次
  • ¥20 西南科技大学数字信号处理
  • ¥15 有两个非常“自以为是”烦人的问题急期待大家解决!
  • ¥30 STM32 INMP441无法读取数据
  • ¥15 R语言绘制密度图,一个密度曲线内fill不同颜色如何实现
  • ¥100 求汇川机器人IRCB300控制器和示教器同版本升级固件文件升级包
  • ¥15 用visualstudio2022创建vue项目后无法启动
  • ¥15 x趋于0时tanx-sinx极限可以拆开算吗