Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Senior Coder Mhtml's Avatar
    Join Date
    Jun 2002
    Location
    Sydney, Australia
    Posts
    3,531
    Thanks
    0
    Thanked 1 Time in 1 Post

    2 response.write(querystring....functions

    I am trying to make a users IP and Browser information come up on the screen if the users selects it from a form.


    <%
    If request.QueryString("browser") = "on" then
    response.write(Request.ServerVariables("http_user_agent"))
    else if request.QueryString("ip") = "on" then
    response.write(Request.ServerVariables("remote_addr"))
    end if
    end if%>

    not sure about the second end if statement, the error that came up before it was in the script told me to put it in.
    Omnis mico antequam dominus Spookster!

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Zwolle, The Netherlands
    Posts
    1,120
    Thanks
    2
    Thanked 31 Times in 31 Posts

    Re: 2 response.write(querystring....functions

    I dont know what the problem is you encountered, but i would do it this way:
    <%
    If request.QueryString("browser") = "on" then
    response.write(Request.ServerVariables("http_user_agent"))
    end if

    if request.QueryString("ip") = "on" then
    response.write(Request.ServerVariables("remote_addr"))
    end if
    %>

    You seem to have two separate checkboxes in your form so the printing of the ip shouldnt be dependant from the printing of the browsername

  • #3
    Senior Coder Mhtml's Avatar
    Join Date
    Jun 2002
    Location
    Sydney, Australia
    Posts
    3,531
    Thanks
    0
    Thanked 1 Time in 1 Post
    Oh, Ok I see what you mean, I'm only new to this. Thanks.
    Omnis mico antequam dominus Spookster!

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    Cincinnati, OH
    Posts
    545
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The problem was that you have two "end ifs" and your using "else if" not "elseif".


    <%
    If request.QueryString("browser") = "on" then
    response.write(Request.ServerVariables("http_user_agent"))
    ElseIf request.QueryString("ip") = "on" then
    response.write(Request.ServerVariables("remote_addr"))
    End If%>

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The problem with using ElseIf in this case, is if the first condition is true, it won't execute the second condition.

    I'd go with roelf's way personally.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #6
    Senior Coder Mhtml's Avatar
    Join Date
    Jun 2002
    Location
    Sydney, Australia
    Posts
    3,531
    Thanks
    0
    Thanked 1 Time in 1 Post
    hmmm....I was wondering why my scripts didn't work with else if. But now i know, thanks Allida77, Whammy + Roelf!.
    Omnis mico antequam dominus Spookster!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •