Solved

Classic ASP If statement not working

Posted on 2014-11-07
6
335 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
FileUp - Classic ASP 5 24
ASP/VB email question 4 59
Call a function within the ASP code 4 26
Diminish Pop-up  in 3 seconds 7 64
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

685 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