gpt4 book ai didi

asp-classic - 经典 ASP (VBScript) 中的 ElseIF 语句

转载 作者:行者123 更新时间:2023-12-04 02:53:28 28 4
gpt4 key购买 nike

这可能非常简单,但我对经典 ASP 语法几乎没有任何经验。基本上我有登录声明。如下图所示:

<%if session("AccountID") = "0" or session("AccountID")=""  then%>
<%
If request.form("SmPress") = "Pressed" Then
dim SQLVerifyEmail
SQLVerifyEmail = "SELECT * FROM Users WHERE UserName= '"&killchars(request.form("UserName"))&"' and Password = '"&killchars(request.form("Password"))&"' AND Status = 'A' AND Deleted = 'no' "
set RSVerifyEmail = MyConn.execute(SQLVerifyEmail)
If RSVerifyEmail.EOF Then

response.write ("<span class=loginerror>Incorrect login details.</span><br>")

Else
LastLogin2 = "UPDATE Users SET LastLogin = Convert(datetime,'"&now()&"',103) WHERE AccountID = '"&RSVerifyEmail("AccountID")&"' "
MyConn.execute(LastLogin2)
session("admin") = RSVerifyEmail("admin")
session("AccountID") = RSVerifyEmail("AccountID")
response.redirect "profile.asp"

End if
End if
%>

我想做的就是拆分它,这样如果 session = admin 它将重定向到 profile.asp,但如果它等于帐户 ID 则重定向到 profile-user.asp。我尝试了以下但它通过大量错误:

ElseIF
LastLogin2 = "UPDATE Users SET LastLogin = Convert(datetime,'"&now()&"',103) WHERE AccountID = '"&RSVerifyEmail("AccountID")&"' "
MyConn.execute(LastLogin2)
session("admin") = RSVerifyEmail("admin") Then
response.redirect "profile.asp"

Else
session("AccountID") = RSVerifyEmail("AccountID")
response.redirect "profile-user.asp"
End if
End if
%>

我哪里错了?

最佳答案

假设您只在数据库的管理员配置文件上设置 RSVerifyEmail("admin") = "True":试一试:

<% if session("AccountID") = "0" or session("AccountID") = ""  then %>
<%
If request.form("SmPress") = "Pressed" Then
dim SQLVerifyEmail
SQLVerifyEmail = "SELECT * FROM Users WHERE UserName= '"&killchars(request.form("UserName"))&"' and Password = '"&killchars(request.form("Password"))&"' AND Status = 'A' AND Deleted = 'no' "

set RSVerifyEmail = MyConn.execute(SQLVerifyEmail)
If RSVerifyEmail.EOF Then
response.write ("<span class=loginerror>Incorrect login details.</span><br>")
Else
LastLogin2 = "UPDATE Users SET LastLogin = Convert(datetime,'"&now()&"',103) WHERE AccountID = '"&RSVerifyEmail("AccountID")&"' "
MyConn.execute(LastLogin2)

' // Set only for admin session only for admins
IF RSVerifyEmail("admin") = "True" Then
RedirectWho = "admin"
session("admin") = RSVerifyEmail("admin")
Else
RedirectWho = "user"
End if
session("AccountID") = RSVerifyEmail("AccountID")
End if
set RSVerifyEmail = Nothing

' // redirect the logged in user or admin
If RedirectWho = "admin" Then
response.redirect "profile.asp"
ElseIf RedirectWho = "user" Then
response.redirect "profile-user.asp"
End if
End if
%>

关于asp-classic - 经典 ASP (VBScript) 中的 ElseIF 语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12603142/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com