-3

我已经使用 ASP 经典创建了一个登录页面。

问题是登录后它重定向到具有相同登录和注册按钮的索引页面,而不是显示用户名或电子邮件ID?

提前致谢...

这是代码(VBScript)。

<%
email = ""
password = ""
ErrorMessage = ""

if request.form <> "" then
email = Request.Form("email")
 password = Request.Form("password")

 if email = "" or password = "" then
 ErrorMessage = "You must specify a username and password."
 else
set conn = Server.CreateObject("ADODB.Connection")
conn.Provider = "Microsoft.Jet.OLEDB.4.0"
 conn.Open("F:\main\main\App_Data\Users.mdb")
 set rs = Server.CreateObject("ADODB.recordset")
rs.Open "Select * FROM Login WHERE Email = '" & email & "'", conn
 response.write("email")

if rs.EOF = false then 

 if rs.fields("Password") = password then
  Response.Redirect("indexs.asp")

end if
 end if 
ErrorMessage = "Login failed"
end if 
end if

if ErrorMessage <> "" then
response.write("<p>" & ErrorMessage & "</p>") 
 response.write("<p>Please correct the errors and try again.</p>") 

end if
%>
4

1 回答 1

0

在重定向到 index.asp 之前设置会话变量,例如

Session("username") = rs("username")

然后,您可以在索引页面上的条件语句中使用会话变量,例如

If session("username") = "" Then

 'your login form goes here

else

response.write "Welcome "+ session("username")

End If
于 2013-03-05T18:12:51.137 回答