473,386 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Stupid question about passing variables

Sorry for the stupid question but I cannot see what I am doing wrong. I found this code to password protect our ASP pages and it works fine but I am trying to pass a variable between pages so I get re-directed to the page I want. I just cannot figure out what I am doing wrong.
Here is the code at the top of the first page. I added the "?Page=linkspda.asp" part
Expand|Select|Wrap|Line Numbers
  1. <%
  2. If Session("BlnLoggedIn") <> True Then
  3. Response.Redirect("http://mywebsite.somewhere.com/login.asp?Page=linkspda.asp")
  4. End If
  5. %>
This does take me to the login.asp page and in the address bar on the browser it shows the "http://mywebsite.somewhere.com/login.asp?Page=linkspda.asp"
The login.asp page looks like this:

Expand|Select|Wrap|Line Numbers
  1. <% 
  2. Response.Expires = -1000 'Make sure the browser doesn't cache this page
  3. Response.Buffer = True 'enables our response.redirect to work
  4. %>
  5.  
  6. <html>
  7. <head><title>Password Protect your ASP pages</title>
  8. </head>
  9. <body>
  10.  
  11. <%
  12. If Request.Form("submit") ="Login" Then 
  13. CheckLoginForm
  14. Else
  15. ShowLoginForm 
  16. End If 
  17. %> 
  18.  
  19. <%
  20. Sub CheckLoginForm
  21. testvar = Request.QueryString("Page")
  22. 'check if the value of the text field 'username' and 'password' are correct
  23. If Request.Form("username") = "test" AND Request.Form("password") = "pass" Then
  24. Session("BlnLoggedIn") = True
  25. Response.Redirect testvar
  26. Else
  27. Response.Write "<div align='center'>You are not logged in.</div><br>"
  28. ShowLoginForm 
  29. End If
  30. End Sub
  31. %> 
  32.  
  33. <% Sub ShowLoginForm %>
  34. <div align='center'>
  35. <!-- start the HTML login form -->
  36. <form name="form" action="login.asp" method="post">
  37. <table>
  38. <tr>
  39.         <td><font size="8">User Name :</font></td>
  40.         <td><input type="text" style="font-size:48px" name="username"></td></tr>
  41. <tr>
  42.         <td><font size="8">Password : </font></td>
  43.         <td><input type="password" style="font-size:48px" name="password"></td></tr>
  44. <tr><td colspan="2"><input type="submit" style="font-size:48px" name="submit" value="Login"></td></tr>
  45. </table> 
  46. </form>
  47. <!-- end the HTML login form -->
  48. </div> 
  49. <% End Sub %> 
  50.  
  51. </body>
  52. </html>
  53.  
After the "Sub CheckLoginForm" I added the line:
testvar = Request.QueryString("Page")
and
Response.Redirect testvar

The Response.Redirect was just:
Response.Redirect "linkspda.asp"

The Request.QueryString("Page") does not seem to contain anything.


What am I doing wrong?

Thanks,
Scott
Sep 27 '10 #1
1 1502
Nicodemas
164 Expert 100+
When the user arrives at login.asp the Query String contains the Page variable. However, when the user submits the form, the Page variable is lost because it is not included in the querystring of the action attribute on the form. You need to include it as a querystring parameter in the action attribute of the form, or you need to include it as a hidden input element of the form; but, if you include it as a hidden element, you will have to test for it using Request.Form since you are using a POST operation.

I personally suggest you just pass it through the form as a hidden element, and change your test using the generic Request().
Sep 29 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: lawrence | last post by:
Those of you with backgrounds with the C language will laugh at my mistake, but those of you, like myself, who deal mostly with PHP should be warned about passing variables as references -...
1
by: Consuelo Guenther | last post by:
Hello, I am having problems with passing variables between pages. I have the following: First asp page has the function: -----------------------------------------------------------------------...
7
by: Khai | last post by:
First off, yes, I understand the crapload of tutorials out there, (well, rather, I understand there /are/ a crapload of tutorials out there), the problem is my comprehension. I'm trying to pass...
2
by: mao120846 | last post by:
I search for an asp vbscript page (residing on a windows web server) that pass a "path" variable to a php page on a different web server (php capable). The php script receive the "path" variable and...
4
by: Jeroen | last post by:
Hi, Assume a function which returns an object of type 'my_class': my_class get_class() { ... } Now I have the following question:
1
satterfieldben
by: satterfieldben | last post by:
I have a newbie question about passing variables between functions. I am wanting to use a drop down box to select a value. Then base on which was selected, it would create a variable and I would call...
6
by: coool | last post by:
Hi :) anyone knows how can I send variables from a php page to a form - i need to fill the form with these variables ? maybe using (the process of passing variables to other pages - through...
8
by: pcaisse | last post by:
Hi. I have a question about passing parameters. Normally if I'm passing two scalars, I do it like this: &my_sub($scalar1, $scalar2); sub my_sub { $val1 = shift; $val2 = shift; # rest...
6
BezerkRogue
by: BezerkRogue | last post by:
This is the most fundamental action I am sure, but I can't seem to make it happen. I am familiar with passing variables in ASP. But that doesn't seem to be the preferred method in .NET. I have...
2
by: peterWolf | last post by:
Hi there, i have a quick question about passing SQL statements to a server. I am using Borland C++ v6 and using MS SQL 2005 express edition. I am new to the world of SQL so would like either a...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.