我使用ASP classic创建了一个登录页面。
问题是登录后它会使用相同的登录和注册按钮重定向到索引页面而不是显示用户名或电子邮件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
%>
答案 0 :(得分:0)
在重定向到index.asp之前设置会话变量,例如
Session("username") = rs("username")
然后,您可以在索引页面上的条件语句中使用会话变量,例如
If session("username") = "" Then
'your login form goes here
else
response.write "Welcome "+ session("username")
End If