ASP Forms "Get" Server Variables

H

Harry

Hi All,

Can anyone clever out there tell me why the below script does not
work!
- I have a page with two radio boxes with values of "agree" and
"not_agree".
- The form is set to GET which goes to the below script for
processing.
- No matter which of the two radio boxes are selected, it always goes
to the page "/broadband/order.asp".
- There is no other code on the form processing page apart form what
is below.
- PLEASE HELP

Thanks
H


<%
if request.ServerVariables("terms_conditions") = agree then
response.Redirect("/broadband/order.asp")
else
response.Redirect("/default.asp")
end if
%>
 
A

Aaron Bertrand - MVP

if request.ServerVariables("terms_conditions") = agree then

Did you mean

if request.QueryString("terms_conditions") = "agree" then
 
R

Ray at

When you use GET with a form you pull values from REquest.Querystring, not
REquest.Servervariables.

Also, you'll want to delimit agree. Try this:

If Request.Querystring("term_conditions") = "agree" Then
Response.Write "It will redirect to order.asp after I am finished
debugging and add the redirect code."
Else
Response.Write "It will redirect to default.asp after I am finished
debugging and add the redirect code. I will never put redirect code in
until I have my conditional statements working propery so that things are
easier to debug. I will use response.write often while debugging, and I
will also often use response.end."
End If



Ray at work
 
T

Tom B

Response.Write "It will redirect to default.asp after I am finished
debugging and add the redirect code. I will never put redirect code in
until I have my conditional statements working propery so that things are
easier to debug. I will use response.write often while debugging, and I
will also often use response.end."


Yes Mom.
 
B

Boris Nikolaevich

In addition to everything else that has been said, using "Option Explicit"
on every ASP page I write has helped me with things like what you
encountered. It is optional (for some, not to me), but in your case it
would have raised an error that you hadn't defined the variable "agree" (no
quotes), helping you to identify the problem sooner.

(and BTW, I have to add with a grin that "Yes, Mom" was appropriate, because
it was said exactly the way I used to say it to my brother when he was doing
his self-righteous finger-wagging. Has nothing to do with gender or with
the fact that Ray was very right about his effective development practices.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top