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 3 of 3
  1. #1
    Kal
    Kal is offline
    Regular Coder
    Join Date
    Dec 2005
    Posts
    309
    Thanks
    0
    Thanked 0 Times in 0 Posts

    if statement redirect help

    Hi guys,

    could anyone help out on why the following code doesn't work.

    baiscally if the logged on username does not equal to one of the four then redirect.

    but the code seem to redirect all the time.

    Code:
    sUsername = ucase(Request.ServerVariables("LOGON_USER"))
    
    response.write sUsername
    
    if ((sUsername <> "bperry") or (sUsername <> "Kal") or (sUsername <> "JPMulholland") or (sUsername <> "steague")) then
    
    Response.Redirect "http://www.google.com"
    
    end if
    thanks inadvance

  • #2
    Regular Coder
    Join Date
    Mar 2007
    Posts
    505
    Thanks
    1
    Thanked 19 Times in 19 Posts
    This is simply a case-sensitivity issue.

    You are calling sUsername = uppercase, while you are trying to compare quoted lower case values.

    Since UPPERCASE <> lowercase, you are always getting redirected.

    Try changing your statement to:

    Code:
    if ((sUsername <> ucase("bperry")) or (sUsername <> ucase("Kal")) or (sUsername <> ucase("JPMulholland")) or (sUsername <> ucase("steague"))) then
    OR much more simply --

    Code:
    sUsername = Request.ServerVariables("LOGON_USER")
    HTH!

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    You should use AND not OR in the condition.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

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