私は自分のプロジェクト用にこのコードを持っており、ユーザー固有のデータを表示するアカウント ページにユーザーを誘導したいと考えています。つまり、サプライヤーのリストです。セッション変数を作成する必要があることはわかっていますが、それをコードのどこに置くべきかわかりません。また、アカウント ページでユーザーを指定するコードもわかりません。誰でも助けることができますか?これが私のコードです。
<%
'Connection String
Dim Conn
'Query to be executed
Dim SQLQuery
'Recordset
Dim rs
'StudentNo Of Logged in user
Dim UserName
'Password of User
Dim Password
'Getting information from submitted form
UserName = request.form("username")
Password = request.form("password")
RememberMe = request.form("rememberme")
'If not blank Username password submitted
if UserName <> "" or Password <> "" then
'Creating connection Object
set Conn=server.createobject("ADODB.Connection")
'Creating Recordset Object
set rs = Server.CreateObject("ADODB.Recordset")
'Initialising Provider String
connStr = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ="& Server.MapPath("database.mdb")&";"
'Opening Connection to Database
Conn.open connStr
'Query to be executed
SQLQuery = "select * from customers_tbl where c_email = '"&UserName&"' AND c_password = '"&Password&"'"
'Retrieving recordset by executing SQL
set rs=Conn.execute(SQLQuery)
'If no records retrieved
if rs.BOF and rs.EOF then
Response.Redirect "customerlogin.htm?username=" & UserName
else
'If remember me selected
if RememberMe = "ON" then
'Writing cookies permanently
Response.Cookies("UserName")=UserName
Response.Cookies("Password")=Password
Response.Cookies("UserName").Expires = Now() + 365
Response.Cookies("Password").Expires = Now() + 365
Response.Redirect "customeraccount.htm"
else
'writing cookies temporarily
Response.Cookies("UserName")=UserName
Response.Cookies("Password")=Password
Response.Redirect "customeraccount.htm"
end if
'Closing all database connections
Conn.Close
rs.close
set rs = nothing
set Conn = nothing
end if
else
'Invalid User
Response.Redirect "customerlogin.htm?UserName=blank"
end if
%>