Solved

Stubborn sessions and request.form

Posted on 2004-10-27
298 Views
Last Modified: 2012-05-05
Hi,

I'm going in circles here.  It seems this worked fine until I went through it a second time, then it just stopped working.

I have a page login.asp.
On login.asp the directory path is stored in a variable called str
There is a link that opens a page in an inline frame which passes the variable str and gives it a sessiion name:

session("storedirectory") = str

I do a response.write session("storedirectory")  which shows up fine.
At first, it showed up on each consecutive page without a problem.  At the end, it passes the variable thriough a form which breaks out of the inline frame back to the current website and a specified file.

After the session did not work the second go round, I tried passing the str variable through a form field and requesting it on the next page, but it will not show up no matter what.

page 1:
<input type="text" name="xyz" size="30" maxlength="50" value="<%=session("storedirectory")%>">

page 2:
dim keepdirectory
keepdirectory = request.form("xyz")
response.write keepdirectory& "OK"

I added the "OK" to be sure that the "Internet was't broken"  (hee hee). and it shows up fine.
But the value does not which displays fine on page 1.


Heeeeeeeeeeeeeeeeeeelp! Please...
0
Question by:Insomniac_PhD
    12 Comments
     
    LVL 15

    Expert Comment

    by:Thogek
    Silly question:
    Is that form a method="get" or method="post"?
    0
     
    LVL 9

    Expert Comment

    by:imnajam
    does your page 1 have the <form method="post">
    0
     
    LVL 48

    Expert Comment

    by:Ryan Chong
    How is your form tag on page 1? Make sure there is not enctype="multipart/form-data" on your form tag..

    Post your page 1 here if necessary

    regards
    0
     
    LVL 48

    Expert Comment

    by:Ryan Chong
    btw, you can always try:

    keepdirectory = request("xyz")

    instead
    0
     
    LVL 3

    Author Comment

    by:Insomniac_PhD
    post
    0
     
    LVL 15

    Expert Comment

    by:Thogek
    If you View Source in your browser on page 1, what does the full <input type="text" ...> tag look like?  (I.e., does the value get written in there?
    0
     
    LVL 3

    Author Comment

    by:Insomniac_PhD
    Yes, I can see it just fine when I view source code.

    I started over and got rid of all my junk and comments.  Here is page 1 below.  I discovered that it is posting to itself then redirecting to the next page (page2) so this must have something to do with why the variable is not passing or why a form field will not pass??

    Argghhh






    <%
    '/////////////////////////////////////////////////////////////////
    '/////////////////////////////////////////////////////////////////
    'This is the session variable that will not pass
    session("directoryholder") = request.querystring("senditx")
    session("directoryholder")
    response.write session("directoryholder") 'This displays fine on this page.
    '/////////////////////////////////////////////////////////////////
    '/////////////////////////////////////////////////////////////////

    Response.expires = 0
    Response.expiresabsolute = Now() - 1
    Response.addHeader "pragma", "no-cache"
    Response.addHeader "cache-control", "private"
    Response.CacheControl = "no-cache"
    %>
    <!--#include file="db.asp"-->
    <!--#include file="aspmkrfn.asp"-->
    <%
    Response.Buffer = True

    ' Get action
    a = Request.Form("a")
    Select Case a
          Case "S": ' Get Search Criteria

          ' Build search criteria for advance search, remove blank field
          search_criteria = ""
          x_licensename = Request.Form("x_licensename")
          z_licensename = Request.Form("z_licensename")
          If x_licensename <> "" Then
                srchFld = x_licensename
                this_search_criteria = "x_licensename=" & Server.URLEncode(srchFld)
                this_search_criteria = this_search_criteria & "&z_licensename=" & Server.URLEncode(z_licensename)
          Else
                this_search_criteria = ""
          End If
          If this_search_criteria <> "" Then
                If search_criteria = "" Then
                      search_criteria = this_search_criteria
                Else
                      search_criteria = search_criteria & "&" & this_search_criteria
                End If
          End If
          x_domainname = Request.Form("x_domainname")
          z_domainname = Request.Form("z_domainname")
          If x_domainname <> "" Then
                srchFld = x_domainname
                this_search_criteria = "x_domainname=" & Server.URLEncode(srchFld)
                this_search_criteria = this_search_criteria & "&z_domainname=" & Server.URLEncode(z_domainname)
          Else
                this_search_criteria = ""
          End If
          If this_search_criteria <> "" Then
                If search_criteria = "" Then
                      search_criteria = this_search_criteria
                Else
                      search_criteria = search_criteria & "&" & this_search_criteria
                End If
          End If
          x_OrderNumber = Request.Form("x_OrderNumber")
          z_OrderNumber = Request.Form("z_OrderNumber")
          If x_OrderNumber <> "" Then
                srchFld = x_OrderNumber
                this_search_criteria = "x_OrderNumber=" & Server.URLEncode(srchFld)
                this_search_criteria = this_search_criteria & "&z_OrderNumber=" & Server.URLEncode(z_OrderNumber)
          Else
                this_search_criteria = ""
          End If
          If this_search_criteria <> "" Then
                If search_criteria = "" Then
                      search_criteria = this_search_criteria
                Else
                      search_criteria = search_criteria & "&" & this_search_criteria
                End If
          End If
                If search_criteria <> "" Then
                      Response.Clear
                      session("directoryholder")
                      Response.Redirect "licensegenlicenseslist.asp" & "?" & search_criteria
                End If
    End Select

    ' Open Connection to the database
    Set conn = Server.CreateObject("ADODB.Connection")
    conn.Open xDb_Conn_Str
    %>
    <script language="JavaScript" src="ew.js"></script>
    <script language="JavaScript">
    <!-- start Javascript
    function  EW_checkMyForm(EW_this) {
    return true;
    }
    // end JavaScript -->
    </script>
    <form onSubmit="return FrontPage_Form1_Validator(this)"  action="licensegenlicensessrch.asp" method="post" language="JavaScript" name="FrontPage_Form1">
    <input type="hidden" name="z_OrderNumber" value="=,','">
    <input type="hidden" name="z_domainname" value="=,','">
    <input type="hidden" name="z_licensename" value="=,','">
    <p>
    <input type="hidden" name="a" value="S">
    <table border="0" cellspacing="0" cellpadding="1" bgcolor="#FFFFFF">
          <tr>
                <td bgcolor="#FFFFFF" colspan="2"><b><font face="Arial" size="2">Step 1
                of 5: Enter your Licensed Name and Order Number below:</font></b></td>
          </tr>
          <tr>
                <td bgcolor="#FFFFFF"><font face="Arial" size="2">
                <span class="appstyle" style="color: #0000FF;">Licensee</span><font color="#0000FF">&nbsp;</font></font></td>
                <td bgcolor="#FFFFFF"><span class="appstyle">
                <!--webbot bot="Validation" s-display-name="Your Licensed Name" b-value-required="TRUE" i-maximum-length="255" --><input type="text" name="x_licensename" size="30" maxlength="255" value="<%= Server.HTMLEncode(x_licensename&"") %>"></span>&nbsp;</td>
          </tr>
          <tr>
                <td bgcolor="#FFFFFF"><font face="Arial" size="2">
                <span class="appstyle" style="color: #0000FF;">Domain</span><font color="#0000FF">&nbsp;</font></font></td>
    <%
    dim myapplicationserver
    getmydomainname = Request.querystring("myapplicationserver")
    %>

                <td bgcolor="#FFFFFF"><span class="appstyle">
                &nbsp;<!--webbot bot="Validation" b-value-required="TRUE" i-maximum-length="255" --><input type="text" name="x_domainname" size="30" maxlength="255" value="<%=getmydomainname%>"></span>&nbsp;</td>
          </tr>
          <tr>
                <td bgcolor="#FFFFFF"><font face="Arial" size="2">
                <span class="appstyle" style="color: #0000FF;">Order Number</span><font color="#0000FF">&nbsp;</font></font></td>
                <td bgcolor="#FFFFFF"><span class="appstyle">
                <!--webbot bot="Validation" s-display-name="Your Order Number" b-value-required="TRUE" i-minimum-length="4" i-maximum-length="50" --><input type="text" name="x_OrderNumber" size="30" maxlength="50" value="<%= Server.HTMLEncode(x_OrderNumber&"") %>"></span>&nbsp;</td>
          </tr>
    </table>
    <p>
    <input type="submit" name="Action" value="Continue to Step 3">
    </form>
    <%
    conn.close
    Set conn = nothing
    %>
    0
     
    LVL 13

    Accepted Solution

    by:
    try to pass the variable as querystring

    <form action="asppage.asp?mydir=<%=session("storedirectory")%>" method="post" enctype="multipart/form-data" name="form1">

    also check the path redirecting tha page into frame
    it should be relative path "page.asp"
    not an absolute path "http://www.mydomain.com/page.asp"
    0
     
    LVL 3

    Author Comment

    by:Insomniac_PhD
    no that does nothing
    0
     
    LVL 3

    Author Comment

    by:Insomniac_PhD
    No hold on, I'm getting something.... just a few minustes..
    0
     
    LVL 3

    Author Comment

    by:Insomniac_PhD
    ok thanks...got it.  
    0
     
    LVL 48

    Expert Comment

    by:Ryan Chong
    instead of setting your variable using querystring like:

    <form action="asppage.asp?mydir=<%=session("storedirectory")%>" method="post" enctype="multipart/form-data" name="form1">

    why don't you put it as a hidden field, while you using POST method?
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    Prepare to Pass the CompTIA A+ 900 Series Exam

    CompTIA aims to adapt its A+ Certification to reflect the most current knowledge and skills needed by today's IT professionals--and this year's 2016 exam is harder than ever. This certification is one of the most highly-respected and sought after in IT.

    Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
    Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    877 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now