Need help passing info from one pg to another

Results 1 to 4 of 4

Thread: Need help passing info from one pg to another

  1. #1
    Join Date
    Dec 1969
    Posts
    1,671

    Default Need help passing info from one pg to another

    Ok guys, I&#039ve been racking my brain...<BR><BR>Background: Creating a site with a public area and a secure area which is broken into three parts. To enter security, they go to LogIn.htm and enter in their name and PW. Then they can choose to go to area 1,2,or 3. This where the problem is. <BR><BR>I can&#039t seem to access the recordset that was made when they logged in. I used an SQL retrieving all info for the person who matched login and password, etc. Now I need to access those records to see if they have yes or no in a certain field. <BR><BR>Here&#039s my code:<BR>LogInValidate - validates the LogIn.htm page where users enter in their login and PW<BR><BR>&#060;%@ Language=VBScript &#037;&#062;<BR>&#060;%Response.Expires = 0&#037;&#062;<BR><BR>&#060;%<BR>&#039 get the users input from the posting<BR>account = Request.QueryString("ACCOUNT")<BR>password = Request.QueryString("PASSWORD")<BR><BR>&#039 incomplete input - have them try again<BR>if account = "" or password = "" then Response.Redirect("LogIn.htm")<BR><BR>&#039 open DB connection<BR>set DBConn = Server.CreateObject ("ADODB.Connection")<BR>DBConn.Open "DSN=WWW_ACCOUNTS;" , "", "" &#039 ODBC driver data set name<BR><BR>&#039 create command<BR>set cmdTmp = Server.CreateObject("ADODB.Command")<BR>cmdTmp.Act iveConnection = DBConn<BR><BR>&#039 build to sql statement<BR>sql = " SELECT * FROM WWW_ACCOUNTS_TABLE "<BR>sql=sql& " WHERE "<BR>sql=sql& " ACCOUNT = &#039" & account & "&#039"<BR>sql=sql& " AND PASSWORD = &#039" & password & "&#039"<BR>cmdTmp.CommandText = sql<BR><BR>&#039 execute the sql statement<BR>set rs = Server.CreateObject("ADODB.Recordset")<BR>rs.Open cmdTmp<BR>Session("LOGGEDIN") = False &#039 assume they will fail<BR><BR>if rs.EOF and rs.BOF then<BR> Response.Write "Sorry Your Login was Not Successful"<BR>else<BR> Session("LOGGEDIN") = True &#039 they are on<BR> Response.Redirect("AnyPage.asp") &#039 send them to secure page<BR> <BR>end if<BR>rs.Close &#039 close the recordset<BR><BR>&#037;&#062;<BR>This works fine. I&#039m able to get them to AnyPage.asp when they enter in the right login and PW. Now notice the rs.Close at the end there. I&#039ve tried this with and w/out it. Let&#039s go on...<BR><BR>Now here is the Include for AnyPage.asp to check if they have access to this particular area:<BR><BR>&#060;%<BR>set DBConn = Server.CreateObject ("ADODB.Connection")<BR>DBConn.Open "DSN=WWW_ACCOUNTS;" , "", "" &#039 ODBC driver data set name<BR><BR>Dim rs<BR>set rs = Server.CreateObject ("ADODB.Recordset")<BR><BR>rs.Open <BR><BR>Dim value<BR>set value = rs("MINXWARE")<BR><BR>if value = "no" then<BR> Response.Redirect("LogIn.htm")<BR>end if<BR><BR>&#037;&#062;<BR>I&#039ve tried just rs.Open before and it kept saying it was invalid or needed a connection so I did all that. How can I access that recordset I made in LogInValidate on another page???<BR><BR>Thanks!, <BR>Mike

  2. #2
    Join Date
    Dec 1969
    Posts
    119

    Default RE: Need help passing info from one pg to another

    Hi Mike,<BR><BR>The recordet you open on one page is not accessible on <BR>other pages. Any connections, recordsets you create are <BR>cleared when that page is executed.<BR><BR>Here is the solution.<BR><BR>In LogInValidate file you store the recordset in a session<BR>variable<BR><BR>Session("rsUserDetails" ) = rs<BR><BR>Now in AnyPage.asp you get this recodset in another var<BR>Set rsX = Server.CreateObject("ADODB.Recordset")<BR>Set rsX = Session("rsUserDetails")<BR><BR>(Just check the Sets..You may not need it in some places)<BR><BR>Then you can again use the recordset.<BR><BR>Other solution : Execute the previos SQL again here(AnyPage).<BR><BR>Hope this helps<BR><BR>Manish<BR><BR>

  3. #3
    Join Date
    Dec 1969
    Posts
    1,671

    Default RE: Need help passing info from one pg to another

    Thanks! I just made it a session variable and now I can carry the info across pages! Woo-hoo! :)<BR><BR>-Mike

  4. #4
    Join Date
    Dec 1969
    Posts
    2,849

    Default RE: Need help passing info from one pg to another

    This is asking for trouble, with a capital T.<BR>Read http://www.activeserverpages.com/learn/nosessionobjects.asp for a thorough explanation why.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •