我的项目有此代码,我希望将用户定向到他们的帐户页面,该页面显示特定于他们的数据。即他们的供应商名单。我意识到我需要创建一个会话变量,但我不知道将它放在我的代码中的哪个位置,而且我不知道在帐户页面中指定用户的代码。任何人都可以帮忙吗?这是我的代码。
<%
'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
%>