View Full Version : if statement redirect help

05-22-2007, 04:12 PM
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.

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

05-22-2007, 04:32 PM
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:

if ((sUsername <> ucase("bperry")) or (sUsername <> ucase("Kal")) or (sUsername <> ucase("JPMulholland")) or (sUsername <> ucase("steague"))) then

OR much more simply --

sUsername = Request.ServerVariables("LOGON_USER")


05-22-2007, 09:50 PM
You should use AND not OR in the condition.