Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2004
    Posts
    43

    Unanswered: passing session info in form

    is it possible to use session variables in a search form?

    I have this form and the login page sets the session and then gets to this page which tries to submit the session variables to search for. Have tried it but cant seem to get it to work. Here is the portion from my form page:

    <td width="6" valign="top"></td>
    <td width="410" valign="top" class="data1">
    <input type="text" name="WorkPhone" value="">
    <input type="hidden" name="loanofficer" value="<%=session("lofficer")%>">

    when I try to pass to my results page it acts as if nothing is being passed

  2. #2
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    That should be fine. How are you trying to read it out again??

    Have you checked the generated html to see if your hidden field actually contains the value??

  3. #3
    Join Date
    Oct 2004
    Posts
    43
    Hey I am trying to pull it into the search form you help me out with.
    So when I log in I get to the search form with the hidden session, and I tried just putting in the session by it self and it displays the info, but when I submit the search from it does not seem to take the hidden form info it just shows all the data from my database. Here is the info from my new results page with the loanofficer field added which is the hidden session info:


    <%@ LANGUAGE=VBScript %>
    <%
    Response.Buffer = True
    Dim connect, recordset, whereclause, query, pageNumber, itemNumber, lineIndex
    lineIndex = 0
    Dim CustomerID
    Dim FirstName
    Dim MiddleInitial
    Dim LastName
    Dim HomePhone
    Dim WorkPhone
    Dim Email
    Dim NoResults
    Dim LoanOfficer
    Set connect = Server.CreateObject("ADODB.Connection") ' Prepare to connect to database
    connect.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath ("db1.mdb")
    pageNumber = CInt(Request("pageNumber"))
    if PageNumber = 0 then
    pageNumber = 1
    ' Get the form information in local variables
    CustomerID = Trim(Request("CustomerID"))
    FirstName = Trim(Request("FirstName"))
    MiddleInitial = Trim(Request("MiddleInitial"))
    LastName = Trim(Request("LastName"))
    HomePhone = Trim(Request("HomePhone"))
    WorkPhone = Trim(Request("WorkPhone"))
    Email = Trim(Request("Email"))
    StartDate = Trim(Request("startdate"))
    EndDate= Trim(Request("enddate"))
    LoanOfficer= Trim(Request("loanofficer"))

    whereclause = "WHERE "
    If CustomerID <> "" Then
    whereclause = whereclause & "Borrowers.CustomerID LIKE '" & CustomerID & "' AND "
    End If
    If LoanOfficer <> "" Then
    whereclause = whereclause & "Borrowers.LoanOfficer LIKE '" & LoanOfficer & "' AND "
    End If
    If FirstName <> "" Then
    whereclause = whereclause & "Borrowers.FirstName LIKE '" & FirstName & "' AND "
    End If
    If MiddleInitial <> "" Then
    whereclause = whereclause & "Borrowers.MiddleInitial LIKE '" & MiddleInitial & "' AND "
    End If
    If LastName <> "" Then
    whereclause = whereclause & "Borrowers.LastName LIKE '" & LastName & "' AND "
    End If
    If HomePhone <> "" Then
    whereclause = whereclause & "Borrowers.HomePhone = " & HomePhone & " AND "
    End If
    If WorkPhone <> "" Then
    whereclause = whereclause & "Borrowers.WorkPhone = " & WorkPhone & " AND "
    End If
    If Email <> "" Then
    whereclause = whereclause & "Borrowers.Email LIKE '" & Email & "' AND "
    End If
    If StartDate <> "" and EndDate <>"" Then
    whereclause = whereclause & Request.Form("searchDate") & " BETWEEN #" & StartDate & "# AND #" & EndDate & "# "
    End If

    If Right(whereclause, 4) = "AND " Then
    whereclause = Left(whereclause, Len(whereclause) - 4) ' strip off 'AND '
    Elseif Right(whereclause, 6) = "WHERE " Then
    whereclause = Left(whereclause, Len(whereclause) - 6) ' strip off 'WHERE '
    End If
    query = "SELECT * FROM Borrowers " & whereclause
    Session("SSS_query") = query
    else
    query = Session("SSS_query")
    end if
    set recordset = Server.CreateObject("ADODB.Recordset")
    recordset.CursorType = 3 ' adOpenStatic
    recordset.PageSize = 20
    recordset.Open query, connect
    if not recordset.eof then
    recordset.AbsolutePage = CInt(pageNumber)
    end if
    %>
    <HTML>
    <title>Borrowers Search Results</title>
    <link rel="stylesheet" href="styles.css" type="text/css">
    <body topmargin=0 leftmargin=0 marginheight=0 marginwidth=0>
    <!--#include file="header.inc" -->
    <img src="logo.gif" width="144" height="75">
    <table width="100%" cellpadding="0" cellspacing="0" border="1" bordercolor="#000000">
    <tr>
    <td>
    <table width="100%" border="0" cellpadding="0" cellspacing="0">
    <tr>
    <td width="10" class="strip">&nbsp;</td>
    <td class="strip">CustomerID</td>
    <td class="strip">FirstName</td>
    <td class="strip">MiddleInitial</td>
    <td class="strip">LastName</td>
    <td class="strip">HomePhone</td>
    <td class="strip">WorkPhone</td>
    <td class="strip">Email</td>
    </tr>
    <%
    NoResults = True
    itemNumber = 0
    Do While Not recordset.EOF and itemNumber < recordset.PageSize
    NoResults = False
    %>
    <% If lineIndex MOD 2 = 0 Then %>
    <tr>
    <td width="10" class="data1">&nbsp;</td>
    <td class="data1"><a class="datalink" href="detailnew.asp?itemNumber=<%=(CInt(pageNumber ) - 1) * recordset.PageSize + itemNumber%>"><%=recordset("CustomerID")%></a></td>
    <td class="data1"><%=recordset("FirstName")%></td>
    <td class="data1"><%=recordset("MiddleInitial")%></td>
    <td class="data1"><%=recordset("LastName")%></td>
    <td class="data1"><%=recordset("HomePhone")%></td>
    <td class="data1"><%=recordset("WorkPhone")%></td>
    <td class="data1"><%=recordset("Email")%></td>
    </tr>
    <% Else %>
    <tr>
    <td width="10" class="data2">&nbsp;</td>
    <td class="data2"><a class="datalink" href="detailnew.asp?itemNumber=<%=(CInt(pageNumber ) - 1) * recordset.PageSize + itemNumber%>"><%=recordset("CustomerID")%></a></td>
    <td class="data2"><%=recordset("FirstName")%></td>
    <td class="data2"><%=recordset("MiddleInitial")%></td>
    <td class="data2"><%=recordset("LastName")%></td>
    <td class="data2"><%=recordset("HomePhone")%></td>
    <td class="data2"><%=recordset("WorkPhone")%></td>
    <td class="data2"><%=recordset("Email")%></td>
    </tr>
    <% End If %>
    <%
    itemNumber = itemNumber + 1
    lineIndex = lineIndex + 1
    recordset.MoveNext
    Loop
    %>
    </table>
    </td>
    </tr>
    <tr>
    <td class="strip">&nbsp;</td>
    </tr>
    </table>
    <br><br>
    <div align="center">
    <table border="0" cellspacing="0" cellpadding="0" class="detail">
    <tr>
    <td>
    <div align="center">
    <%
    If pageNumber > 1 Then
    %>
    <table width="150" border="1" bordercolor="#000000" bgcolor="#cccccc" cellpadding="0" cellspacing="0">
    <tr>
    <td class="button">
    <div align="center">
    <p><a class="button" href="search_results.asp?pageNumber=<%=pageNumber - 1%>">PREVIOUS</a></p>
    </div>
    </td>
    </tr>
    </table>
    </div>
    </td>
    <td>
    <div align="center"> </div>
    </td>
    <td>
    <div align="center">
    <%
    End If
    if not recordset.EOF then
    %>
    <table width="150" border="1" bordercolor="#000000" bgcolor="#cccccc" cellpadding="0" cellspacing="0">
    <tr>
    <td class="button">
    <div align="center">
    <p><a class="button" href="search_results.asp?pageNumber=<%=pageNumber + 1%>">
    NEXT</a></p>
    </div>
    </td>
    </tr>
    </table>
    <%
    end if
    %>
    </div>
    </td>
    </tr>
    </table>
    <br>
    <%
    if NoResults = True Then
    %>
    Sorry, no records in the database matched your search parameters. Click Back
    and try again.
    <%
    End If ' No match
    %>
    </div>
    <p align="center"><br>
    <div align="center">
    <table width="540" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td>
    <div align="center">Click on the hyperlinks in the leftmost column for
    more information. </div>
    </td>
    </tr>
    </table>
    </div>
    </BODY>
    </HTML>

  4. #4
    Join Date
    Oct 2004
    Posts
    43
    nevermind i cant spell


    mispelling in hidden session info

  5. #5
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    Well I can't see anything that should stop it from working but why pass the value like that? why not just grab it from the session??

    So this line
    Code:
    LoanOfficer= Trim(Request("loanofficer"))
    becomes
    Code:
    LoanOfficer= session("lofficer")
    If you can't do this post the orginal page that sets the hidden value and I will see if I can find anything there that could be causing the problem.

  6. #6
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    heheheh common enough mistake

Posting Permissions

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