Check Querystring

D

Deepster

Hi Guys
Here is what I am doing ... Have a page default.asp which looks at the
url and checks for querystring's. if there are none passed goes to a
function. if there are particular querystrings passed goes to the
respective function.
Now there can be only 2 valid querystrings that can be passed and only
one at a time. How to do i check for querystrings that dont exist and
send them to error page?

for example I have QS(querystring) ID and State. only one can exist at
a time or none. if I pass QS country along with one of those two, it
still goes to that function. Can I look for querystring that shouldnt
be valid in my case and redirect them to error page?

Here is my code! thanks

***********************

If (Request.QueryString("ID") <> "") Then
If (Request.QueryString("State") <> "") Then
Response.Redirect("error.asp")
Else
rs__MMColParam = Request.QueryString("ID")
display()
End if
Else if (Request.QueryString("State") <> "") Then
statereq = Request.QueryString("State") 'statereq --- State requested
select case statereq
case "AL"
alreq()
case "AZ"
azreq()
case "CO"
coreq()
case "FL"
flreq()
case "IN"
inreq()
case "MI"
mireq()
case "OH"
ohreq()
case "OR"
orreq()
case "VA"
vareq()
case "WA"
wareq()
case "APTS"
aptsreq()
case else
Response.Redirect "error.asp"
end select
Else
normal()
End If
End If
 
P

Phill. W

Deepster said:
Now there can be only 2 valid querystrings that can be passed and only
one at a time. How to do i check for querystrings that dont exist and
send them to error page?

For Each eArg in Request.QueryString
Select Case eArg
Case "ID"
' We were given an ID - deal with it
' Check for QS( "State" ) as well, or simply give ID priority

Case "State"
' We were given a State - deal with that

Case Else
' Don't know /what/ this is ...
' Off the error page we go ...

End Select
Next

HTH,
Phill W.
 
T

teknohippy

Here is my code! thanks

***********************

If (Request.QueryString("ID") <> "") Then
If (Request.QueryString("State") <> "") Then
Response.Redirect("error.asp")
Else
rs__MMColParam = Request.QueryString("ID")
display()
End if
Else if (Request.QueryString("State") <> "") Then
statereq = Request.QueryString("State") 'statereq --- State requested
select case statereq
case "AL"
alreq()
case "AZ"
azreq()
case "CO"
coreq()
case "FL"
flreq()
case "IN"
inreq()
case "MI"
mireq()
case "OH"
ohreq()
case "OR"
orreq()
case "VA"
vareq()
case "WA"
wareq()
case "APTS"
aptsreq()
case else
Response.Redirect "error.asp"
end select
Else
normal()
End If
End If


What do the XXreq() functions do? Smells like there's lots of code
replicated in them and you'd be better of with a single function and
an argument?
 
D

Deepster

Thanks for your help guys!

As for describing how the site works, well user comes to my page gets
the default page. If the user wants more information on state basis the
default page loads with the querystring "State" and then I do select
case to direct them to each functions. Once inside the state page they
can click on individual results, this is where the querystring "id"
comes into play and is passed on to the default page.
Phil, I will try the code out and let you know how it goes.

Thanks
 
A

Adrienne

Thanks for your help guys!

As for describing how the site works, well user comes to my page gets
the default page. If the user wants more information on state basis the
default page loads with the querystring "State" and then I do select
case to direct them to each functions. Once inside the state page they
can click on individual results, this is where the querystring "id"
comes into play and is passed on to the default page.
Phil, I will try the code out and let you know how it goes.

Thanks

Totally OT for this group, but if you can rename "id" to something else,
you're not going to have problems with Google spidering it. Google won't
spider URIs with "id" in the string.
 

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,013
Latest member
KatriceSwa

Latest Threads

Top