Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

request url parameter

Status
Not open for further replies.

jacob94

Technical User
Dec 5, 2005
161
US
I just can't figure this one out. I have a basic asp page with a link
It takes you to the login page in which the user logins into the website username and password.

At the end of the login code (setting session variables etc) I want to redirect my user to page1.asp if they have a urlRedirect of 1 and page0.asp if they have a 0.

This works if I hard code in the variable urlRedirect = 1 etc.

When I try:
Trim(Request("urlRedirect"))
Request("urlRedirect")
Request.QueryString("urlRedirect")

they all fail... It will not read the url param no matter what I try. Any ideas?
 
Sorry but I dont really understand your question...

Request.QueryString("urlRedirect")

Will return "1"

you then want to use

Code:
if Request.QueryString("urlRedirect")=1 then
response.redirect "page1.asp"
else
response.redirect "page2.asp"
end if

if this is what you are trying and still getting an error then can you tell us what error you are getting?

nick
 
if Request.QueryString("urlRedirect")="1" then
---
else
---
end

should work...can you try changing the variable name to something else besides urlRedirect

-DNG
 
If user follows a link to login.asp?urlRedirect=1

And then user submits form with username and password

and then ASP logic validates username and password

And then redirect based on value of "urlRedirect"

If everything above is true then the value arrives correctly when the login page is loaded but it is not pushed forward when the form is submitted.

To carry the value along, you might use a hidden form element, something like this:[tt]
<input type="hidden" name="urlRedirect" value="<%= Request("urlRedirect")%>">[/tt]


Another approach is to change the form tag by adding the value to the action page:[tt]
<form method="post" action="login.asp?urlRedirect=<%= Request("urlRedirect")%>"> [/tt]



 
Thanks for the quick responses!

This is exactly what I am doing :

if urlRedirect=1 then
response.redirect "page1.asp"
else
response.redirect "page2.asp"
end if

It does not recognize the urlRedirect when the user clicks login (runs that code). If I place this above:
if Request.ServerVariables("Content_Length") > 0

it will display a response.write of the urlRedirect variable.

I am not sure what is going on and have tried everything...
 
Is this what your doing?
1) User goes to some page
2) User follows link to login page with Redirect in querystring
3) User types in their username and password and presses a button to login
4) Login is processed successfully and now you want to redirect them

If this is correct then your querystring value will be available on step 3, but it will not be available on step 4 unless you have added it to the form action address that the user follows when they press the assumed button in step 3.

 
Thanks so much for the help.

Here is what I have now,
<form method="post" "<% = Request.ServerVariables("SCRIPT_NAME") %>">


How do I add this and do I need both?

action="login.asp?urlRedirect=<%= Request("urlRedirect")%>"

What is the best way to pass url parameters through a couple of create a new user screens from a hyper link. What is the best method?
 
I think you pretty much have it. As long as your user didn't come directly to this login page, then you will be passing along the value from the previous page, exactly like you want to.

 
Thanks so much for the help. One other question.

Here is what I have now,
<form method="post" "<% = Request.ServerVariables("SCRIPT_NAME") %>">


How do I add this to what I have above?

action="login.asp?urlRedirect=<%= Request("urlRedirect")%>"

How do you have to action statements?
 
Like this:
Code:
<form method="post" "<% = Request.ServerVariables("SCRIPT_NAME") %>" action="login.asp?urlRedirect=<%= Request("urlRedirect")%>" >

------------------------------------------------------------------------------------------------------------------------
"Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."
- Winston Churchill
 
You left the action off in your example and Chopstik took you a little too literally :)

Code:
<form method="post" action="<%=Request.ServerVariables("SCRIPT_NAME") %>?urlRedirect=<%= Request("urlRedirect")%>" >

[b]or[/b]

<form method="post" action="<%=Request.ServerVariables("SCRIPT_NAME") & "?urlRedirect=" & Request("urlRedirect")%>" >

-T

 
[blush]
Yeah, literally, I'm like that a lot... [lol] (Thanks for the save, Tarwn)

------------------------------------------------------------------------------------------------------------------------
"Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."
- Winston Churchill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top