Forums

This topic is locked

Record sets and session variables

Posted 08 Mar 2003 01:23:45
1
has voted
08 Mar 2003 01:23:45 Leesa Lavigne posted:
I have two recordsets. One that will display the users ?personal information? and a second one that will display their ?business information? if they have any.

After using the MM login server behavior I am trying to set up session variables that are populated from the recordset information. The business information recordset filters using ?Session variable of UserID? which is created from the first recordset.

For test purposes, after the user logs in they are redirected to a page that displays the session variable and the value. Upon first visit to the page the user information is shown but not the business information. And you get an error message because the second half of the page can?t be displayed until the session variables are set. If you ?refresh? the page the business information shows up along with the second half of the page.

My thought process must be going in the right direction but wrong?.. I?d like to avoid using two pages to create the session variables. I take it the session variables are not created and usable until the page is refreshed. A better way???

You can view it by going to www.loveitsimple.com/MHA/admanagement/login.asp


CODE:
<% Session("email" = Session("MM_Username" %>
<%
Dim rsUserInfo__MMColParam
rsUserInfo__MMColParam = "1"
If (Session("email" <> "" Then
rsUserInfo__MMColParam = Session("email"
End If
%>
<%
Dim rsUserInfo
Dim rsUserInfo_numRows

Set rsUserInfo = Server.CreateObject("ADODB.Recordset"
rsUserInfo.ActiveConnection = MM_MobileHomeAds_STRING
rsUserInfo.Source = "SELECT UserID, FirstName, LastName, B_Address1, B_Address2, B_City, State, B_Zipcode, Phone, email, AdvertiserType, LastLogin FROM PersonalInfo WHERE email = '" + Replace(rsUserInfo__MMColParam, "'", "''" + "'"
rsUserInfo.CursorType = 0
rsUserInfo.CursorLocation = 2
rsUserInfo.LockType = 1
rsUserInfo.Open()

rsUserInfo_numRows = 0
%>
<%
Dim rsBusinessInfo__MMColParam
rsBusinessInfo__MMColParam = "1"
If (Session("UserID" <> "" Then
rsBusinessInfo__MMColParam = Session("UserID"
End If
%>
<%
Dim rsBusinessInfo
Dim rsBusinessInfo_numRows

Set rsBusinessInfo = Server.CreateObject("ADODB.Recordset"
rsBusinessInfo.ActiveConnection = MM_MobileHomeAds_STRING
rsBusinessInfo.Source = "SELECT UserID, BusinessName, BusinessPhone, Website FROM BusinessInfo WHERE UserID = " + Replace(rsBusinessInfo__MMColParam, "'", "''" + ""
rsBusinessInfo.CursorType = 0
rsBusinessInfo.CursorLocation = 2
rsBusinessInfo.LockType = 1
rsBusinessInfo.Open()

rsBusinessInfo_numRows = 0
%>


<html>
<head>
<title>Check Login Information</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<%
Dim strName, strValue, AdType
For Each strField in rsUserInfo.Fields
strName = strField.Name
strValue = strField.Value
Session(strName) = strValue
Response.write (strName & " = " & Session(strName) & "
"
Next
(NOT SURE IF THIS LITTLE FILTER WORKS YET)
If Not Session("AdvertiserType" = "Personal" Then
For Each strField in rsBusinessInfo.Fields
strName = strField.Name
strValue = strField.Value
Response.write (strName & ", " & strValue & "
"
Session(strName) = strValue
Next
Else
Response.write ("Advertiser is Personal"
End If

%>
<p> </p>
<p>INFO REPEATED: above = loop through database to retreive field names and values.
Below = the field names are typed in and session variables are dynamic. </p>
<p>Email: <%= Session("email" %> </p>
<p>Password: shouldn't be shown: <%= Session("Password" %></p>
<p>First Name: <%= Session("FirstName" %></p>
<p>Last Name: <%= Session("LastName" %></p>
<p>Billing Address 1: <%= Session("B_Address1" %></p>
<p>Billing Address 2: <%= Session("B_Address2" %></p>
<p>Billing City: <%= Session("B_City" %></p>
<p>State: <%= Session("State" %></p>
<p>Billing Zipcode: <%= Session("B_Zipcode" %></p>
<p>Phone: <%= Session("Phone" %></p>
<p>Advertiser: <%= Session("AdvertiserType" %></p>
<p>PSWD: Why two password fields: <%= Session("PSWD" %></p>
<p>Business Name: <%= Session("BusinessName" %></p>
<p>Business Phone: <%= Session("BusinessPhone" %></p>
<p>Website: <%= Session("Website" %></p>
<p>Active User: <%= Session("Active" %></p>
<p>Last Login: <%= Session("LastLogin" %></p>
<p>UserID: <%= Session("UserID" %></p>
<p>SelectState: <%= Session("SelectState" %></p>
<p>sLinks: Filter for category: <%= Session("sLinks" %></p>
</body>
</html>
<%
rsUserInfo.Close()
Set rsUserInfo = Nothing
%>
<%
rsBusinessInfo.Close()
Set rsBusinessInfo = Nothing
%>



Referring URL 1: www.loveitsimple.com/MHA/admanagement/login.asp


Thanks for any help!

Reply to this topic