...

View Full Version : if statement redirect help



Kal
05-22-2007, 03: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

Daemonspyre
05-22-2007, 03: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")


HTH!

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum