-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 に答える