Solved

Classic ASP If statement not working

Posted on 2014-11-07
6
311 Views
Last Modified: 2014-11-07
if session("pkContactID")<>request("pkContactID") or session("userlevel")<>"4" then
%>
You do not have sufficient permissions to edit this account!
<%
else

end if

Open in new window


We have a problem with the conditional statement above, it is not going into the else part of the statement.
I have checked the values for the session("pkContactID") and request("pkContactID") and they are the same but yet it sill does not go into the else.
When I dont have the or clause and just check session("userlevel") it goes into the else but as soon as I include the additional or condition it fails.
Am I missing some logic or is ASP being quirky?

If anyone can help that would be awesome.

Thanks.
0
Comment
Question by:Sevron
  • 3
  • 2
6 Comments
 
LVL 15

Expert Comment

by:gladxml
ID: 40427886
try this might help

if (Trim(session("pkContactID"))<>Trim((request("pkContactID")) or session("userlevel")<>"4") then
%>
You do not have sufficient permissions to edit this account!
<%
else

end if
0
 
LVL 17

Expert Comment

by:selvol
ID: 40427890
<%If Session("pkContactID") ..........................................then %>
You do not have sufficient permissions to edit this account!
<%Else%>
 WHAT ELSE
<%End If%>

Open in new window


sElvol
0
 

Author Comment

by:Sevron
ID: 40427892
Hi thanks for the reply.
We tried that also however it did not help.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 15

Expert Comment

by:gladxml
ID: 40427896
it might be you are trying to compare string and numbers

try this

Cstr(session("pkContactID"))<>Cstr((request("pkContactID"))
0
 
LVL 15

Accepted Solution

by:
gladxml earned 500 total points
ID: 40427900
you can try the code below

<%
if Cstr(session("pkContactID"))<>Cstr((request("pkContactID"))  or  Cstr(session("userlevel"))<>"4")  then
%>
You do not have sufficient permissions to edit this account!
<%
else

end if
%>

HTH
0
 

Author Closing Comment

by:Sevron
ID: 40427938
Thanks, I managed to fix it with the following code.
By Using Trim and Cstr and also changing the or to an and.

if session("userlevel")<>"4" and Trim(CStr(session("pkContactID")))<>Trim(CStr(request("pkContactID"))) then
%>
You do not have sufficient permissions to edit this account!
<%
else

end if

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now