Login with conditions problems

What is wrong with this function? I am trying to create a
user login that
checks to make sure the user is in the database first, then
check the active
level. If the level is 1 then set sessions and redirect, if 2
then redirect
to the login page and send a URL variable of
account=suspended, if 0 then
redirect to the login page sending a URL variable of
account=inactive, etc.
I want to query the db first to see if the user is in the
datasbase. If yes,
then check the active number. I am getting this error in the
conditional
statement to check the 'active' column.
'You have attempted to dereference a scalar variable of type
class
java.lang.String as a structure with members'
What am I missing?
<cffunction name="UserLogin" access="remote"
returntype="void">
<cfargument name="username" type="string"
required="yes">
<cfargument name="password" type="string"
required="yes">
<cfquery name="login" datasource="***">
Select username, password, priv FROM users_database
WHERE username='#arguments.username#' AND
password='#arguments.password#'
</cfquery>
<cfif login.recordcount NEQ 0>
<cfif login.active EQ 1>
<cflock scope="session" timeout="30" type="exclusive">
<cfset Session.MM_Username = #arguments.username#>
<cfset Session.SitePriv = #login.priv#>
</cflock>
<cflocation url="/clinic/contribute/main/index.cfm"
addtoken="no">
<cfelseif login.active EQ 0>
<cflocation
url="/clinic/contribute/index.cfm?account=inactive"
addtoken="no">
<cfelseif login.active EQ 2>
<cflocation
url="/clinic/contribute/index.cfm?account=suspended"
addtoken="no">
<cfelseif login.active EQ 3>
<cflocation
url="/clinic/contribute/index.cfm?account=banned"
addtoken="no">
</cfif>
<cfelse>
<cflocation
url="/clinic/contribute/index.cfm?login=failed" addtoken="no">
</cfif>
</cffunction>

Sabaidee as covered why your code didn't work. here's some
more pointers
where your code could be improved...
> <cffunction name="UserLogin" access="remote"
returntype="void">
Set output="false" on all methods unless you actually are
outputting stuff
from them (which generally you should not).
I doubt this method would be appropriate for calling as a
webservice (given
it ends with a <cflocation>), so don't expose it as
one. access="public".
Add hints to all your <cffunction> and
<cfargument> tags. It assists
sanity checking and code documentation.
> <cfquery name="login" datasource="***">
You have not VARed the login variable. This is poor practice
unless you
explicitly mean to not VAR it.
> WHERE username='#arguments.username#' AND
password='#arguments.password#'
Always use <cfqueryparam> tags. It improves performance
and reduces memory
consumption on your DB server.
> <cflock scope="session" timeout="30"
type="exclusive">
> <cfset Session.MM_Username = #arguments.username#>
> <cfset Session.SitePriv = #login.priv#>
> </cflock>
There's no need to lock this sort of variable assignment.
> <cflocation url="/clinic/contribute/main/index.cfm"
addtoken="no">
It's pretty poor practice to use <cflocation> within a
function. You CFM
page should call a method, and get a response back from it.
And then the
CFM page should decide whether to <cflocation> or not.
Possibly your
function should set the URL for the <cflocation> and
return the value.
Then the calling code should use than in a <cflocation>
call.
> <cfelseif login.active EQ 0>
This if/elseif/else construct would be better done as a
switch. Rule of
thumb: evaluating the same variable for many conditions:
switch.
evaluating different variables for many conditions:
if/elseif/else.
Adam

Similar Messages

  • Trigger with Condition problem - insert only when not exists

    Hello experts!
    I have a problem with a trigger I'm trying to create. It compiles but I receive an error message when the trigger fires.
    The scenario is as follows:
    I have a table TBL_PUNKTDATEN. Whenever the status for a record in that table is changed to 3 or 4 I need the trigger to insert a dataset into my target table (TBL_ARBEIT_ZU_GEBIET).
    However, the trigger must only insert data when there's no existing record in the target table. The condition that specifies whether there is a dataset or not, is the field LNG_GEBIET, which exists in the source as well as in the target table. Hence, for each LNG_GEBIET there can be only one dataset in the target table!
    I created a trigger using the following code. However it doesn't work.
    Maybe you'll see what I want to achieve when having a look at my code.
    Can you please help me out on this one?
    Thanks a lot!
    Sebastian
    create or replace
    TRIGGER set_status_arbeit_zu_gebiet AFTER
      UPDATE ON TBL_PUNKTDATEN FOR EACH ROW WHEN(new.INT_STATUS=3 or new.INT_STATUS=4)
    declare
        cursor c is select LNG_GEBIET from TBL_ARBEIT_ZU_GEBIET where PNUM = 1114 and LNG_GEBIET=:new.LNG_GEBIET;
        x number;
    begin
        open c;
        fetch c into x;
        if c%NOTFOUND  then 
        INSERT INTO TBL_ARBEIT_ZU_GEBIET
            LNG_GEBIET,
              LNG_ARBEITSSCHRITT,
              PNUM,
              INT_BEARBEITER,
              DATE_DATUM,
              GEPL_DATUM
            VALUES
            (:new.LNG_GEBIET,
             52,
             1114,
             895,
             sysdate,
             to_date('01.01.1990', 'DD.MM.YYYY')
        end if;
    end;Well, on the first insert the code works properly and inserts the recordset as expected. However, if there is an existing recordset where :new.LNG_GEBIET matches LNG_Gebiet in my target table, I receive the ORA-06502 error!
    Maybe that spcifies it a little bit???
    Hope you can help me!
    Thank you!
    Edited by: skahlert on 23.09.2009 10:26
    Edited by: skahlert on 23.09.2009 10:28

    Thank you very much Peter G!
    That %Rowtype mod did the trick! Great solution! Thanks! The trigger works principally if there wasn't the fact that it fires also when the status of one individual record is 3 or 4.
    I need it to fire only when all records with the same attribute LNG_GEBIET (by the way, you guess was right - it's not a number) are of status 3 or 4.
    Is it possible to use the cursor function for the trigger's when condition?
    Such as:
    declare
        cursor c3 is select COUNT(*) from TBL_PUNKTDATEN where LNG_GEBIET=:new.LNG_GEBIET;and
    declare
        cursor c4 is select COUNT(*) from TBL_PUNKTDATEN where INT_STATUS = 3 and  LNG_GEBIET=:new.LNG_GEBIET or INT_STATUS = 4 and  LNG_GEBIET=:new.LNG_GEBIET;
      And then subsequently somehow compare the results of both cursors?
    ... WHEN c3=c4
    declare
        cursor c2 is select LNG_GEBIET from TBL_ARBEIT_ZU_GEBIET where PNUM = 1114 and LNG_GEBIET=:new.LNG_GEBIET;
        v_c2  c2%ROWTYPE;
    begin
    open c2;
    fetch c2 into v_c2;
    if c2%notfound then
            INSERT INTO TBL_ARBEIT_ZU_GEBIET
            LNG_GEBIET,
              LNG_ARBEITSSCHRITT,
              PNUM,
              INT_BEARBEITER,
              DATE_DATUM,
              GEPL_DATUM
            VALUES
            (:new.LNG_GEBIET,
             52,
             1114,
             895,
             sysdate,
             to_date('01.01.1990', 'DD.MM.YYYY')
            end if;
            close c2;
    end;Please excuse me if the attempt is simply stupid!
    Sebastian
    Edited by: skahlert on 23.09.2009 15:36
    I just saw your reply Max! Thank you! Now I understand far better! Seems to be a successful day! I'm learning a lot! Will also test that method!
    If we could find a solution to the problem I described above it would make it a perfect day! I'm continously trying different attempts to have the trigger only fire when all records are 3 or 4.
    Not that you think I'm just waiting for your answers! That's not the case!
    Thank you all!
    Edited by: skahlert on 23.09.2009 17:30

  • Login with facebook problem

    It is working. But it continiously disconnects and you need to login again. It`s very annoying. I am using Chrome Version 30.0.1599.101 m.
    Lenovo ThinkPad T530: i7-3520M/16GB RAM/128GB Vertex 4 SSD/1TB Seagate HDD + 8GB SSD Cache/NVS 5400M/FHD 1920x1080/9-cell BAT/ Backlit RU/Windows 7 Pro SP1 x64 ENG

    Hello and welcome to the Spotify Community!
    I'll escalate this to Support, they'll answer you asap.

  • Got a new MacBook pro but for some reason I can't connect to my schools wireless. It doesn't have a problem connecting to any other wifi. My schools network is unsecured all you do is login with your username and password but the window never loads

    I jus got a MacBook pro and Im having trouble connecting to my schools network. It is not secured and only requires to login with school id. A Window pops up to sign in but it never loads anyone know why I'm having this problem? Doesn't have a problem connecting to any other wifi

    "This is a flaw in OS X Lion. It does not want to connect to open WiFi that has a login page that open in a browser."
    Nonsense, no problems logging in at sites that you mention. I use OpenDNS servers. For the OP try:
    System Preferences>Network>Advanced>DNS. In the left side column click on the + sign and insert the following:
    208.67.222.222
    208.67.220.220
    Then click OK, then click Apply.

  • Problem in login with sys

    hi,
    i have a problem in login with sys, the situation as follows:
    1- when i try to connect using : sqlplus "/as sysdba" or "sys/password as sysdba" it connect me to the DB.
    2- when i try to connect : sqlplus "sys/password@MYDB as sysdba" it gives me "ORA-01017: invalid username/password; logon denied".
    3- when i try to connect with another user i.e : sqlplus "system/password@MYDB" it connect me to the DB.
    DB version : 9.2.0.8
    OS version : Solaris 10
    please advice...

    1- when i try to connect using : sqlplus "/as sysdba"
    or "sys/password as sysdba" it connect me to
    the DB.This works anyway, because you're authenticated by OS. Example :
    SQL> conn sys/aaaa as sysdba
    Connected.
    SQL> conn sys/bbbb as sysdba
    Connected.
    SQL>
    2- when i try to connect : sqlplus "sys/password@MYDB
    as sysdba" it gives me "ORA-01017: invalid
    username/password; logon denied".Here you need the real password, so make sure you're using the correct one.

  • TS2972 First night I was able to watch 2 TV shows (45 min each) with no problems, but thereafter programs will not stream without constant pause to buffer. Weather conditions are ideal and my internet comes from crappy hugesnet, but worked fine the first

    First night I was able to watch 2 TV shows (45 min each) with no problems, but thereafter programs will not stream without constant pause to buffer. Weather conditions are ideal and my internet comes from crappy hugesnet, but worked fine the first night.

    The speed may have been ok at that time and is too inconsistent/too slow overall. interference may have proven to be more of an issue since as well. If using public DNS that will provide Intermittant results
    I'm sure using a hotspot would be fine but it depends on your viewing habits. An HD movie is around 4-5GB. It would also be subject to speed. requirements so best to test to see how it compares.
    You would have to check with your Carrier if hotspot it's enabled then just to into your settings and toggle it ON

  • Why can I login to iTunes from my phone with no problem, but I can't login to iTunes from my desktop.

    Why can I login to iTunes from my phone with no problem, but I can't login to iTunes from my desktop using the same login credentials. I can use a different appleID and login to itunes with no problem.

    Thanks for your reply.  I mean that only when all of my music in the cloud is shown on my phone can I delete the music stored on my phone.  I should be able to delete music that is stored on my phone when I can view ONLY the music that is taking up the phone's memory.

  • TS4001 Anybody having problems accessing Adwords Exspress login with Safari ?

    Anybody having problems accessing Adwords Exspress login with Safari ?

    Hi jhankins,
    There was a problem yesterday for a brief half an hour to 1 hour, please let us know if you are still facing that issue.
    -Ankit

  • Problem:Member is Read only Mode after login with other user

    Dear,
    I am facing problem to enter the data in member. i.e Read only. but same member is fine with login with admin user.
    I also assign the security with write permission to user. but the only that member "X" is in read only mode..
    Is task list can effect on that??? as i am also using task list. Becoz when i add another member that is not member of that hirechiary its fine.
    I am working on hyperion version 11.1.2.1..
    Regards,
    AMSI

    Thanks, Problem has been solved myself becoz when i add new member in the form as this form is already part of Planning Unit Hierarchy , that's why the newly added member in the form can't be write only till up to when u add this member into Planning Unit Hierarchy.
    Regards,
    AMSI

  • Apple tv 2 problem: I can not login with my ID account!!!!!

    apple tv does not login with my ID! Do you have a solution? Since a few weeks I can not login in with my password...
    I tried everything:
    - re-starting apple tv.
    - login on macbook with my apple ID with new password

    Signal Strengh on WiFi was great (its a new Apple Time Capsule and has to be reset often).  Checked the internet connectivity on other machines too (incase that was inop).   I checked the network first as that is typically a impediment to all other things working prior to my previous comment.  I logged in to iTunes and MobleMe to see that my password was correct and working.  hmmm.
    I reset the Apple TV next and again changed my iTunes password on my laptop, then ran a network test (which needs a itunes password to work).  Network check was successful and I am logged back in.
    Now it says...."Netflix is currently unavailable. Try again later".
    geez.

  • Problem in CMC login with SAP authentication type

    Hi,
    We have installed the SAP Integration kit successfully for BO XI R2 & when I logon to CMC i am able to enable the SAP authentication and import the roles from the SAP BW system as well. But when I try to login into CMC using the 'Authentication type' as SAP it doesn't display the textboxes for entering  System ID and Client details. Can you please tell me how to fix this?
    Also I see that the CMC & Infoview authentication type drop down list are not the same. The CMC has the authentication types available as 'SAP,LDAP & Enterprise' where as Infoview has 'Enterprise, LDAP & AD'.
    Is this an issue with the Plugins? do i need to do some settings on the Tomcat ?
    Please help me out in this..
    Thanks in advance!
    Phani.

    Thanks for your update Jac...yes thats correct. Also I had to include authPlugExt.properties file in the tomcat/shared/classes, which i did not include previously. The SAP infoview is working fine now.
    Just one more question, in CMC login doesn't the SAP authentication require sap system & client id as its inputs? (in XI R2). I noticed that I was able to login with SAP user id's (without mentioning system details) , that have been added when I have imported the SAP roles to BO.

  • Problem in login with scott/tiger in SQL Plus

    Hi,
    I want to login with Scott/Tiger in SQL Plus, I have client on my machine, I can connect to any database by entering entry in tnsnames.ora file, but when I try to login with scott/tiger, Protocol adapter error comes, Do I need to enter any thing in tnsnames.ora file? if yes, please tell me the entries,
    Thanks
    Nidhi..

    I have modified tnsnames.ora file, Below is this file
    ORCL =
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = ORCL)
    Now i ger error
    Error: ORA-12541: TNS: no listener
    Regards,
    Nidhi..

  • Firefox won't load any web site under my login, if I use another account it works fine, this problem start with 7.01 update. I have 8.0 now, other browser works fine with no problem.

    unable to load any web site, no error message, just a blank page.
    safari and chrome work fine, in fact I am using chrome to type this up. This problem only limited to my account, I have created other account and firefox work as it should with no problem. I am unsure with else to clear to get firefox working again.

    Update: This is NOT just related to "Yahoo" pages, while this problem first began with some of my Yahoo pages, it is now also happening with other NON Yahoo things I want to load up. Like Twitter, or Links in emails that load Blank, or even images within emails that show up Blank in the preview part of Yahoo mail. It is NOT a Yahoo issue as I have loaded up my Yahoo Mail in IE and Chrome, and everything loads wonderfully. I can even load up sites like Twitter, and other websites that will NOT load in Firefox, but they come up fine in other Browsers.
    I have done the ONLY suggestion that came from Firefox Tech support, to load up FF in Safe Mode, but the problems still exists. I have uninstalled FF and re-loaded it, but the same problem is there.
    Does anyone have any ideas here at all? I can't seem to get any Fire Fox help, so I am reaching out to the community here to see if anyone can help.... Thank you !!

  • Hello there! am new to mac and had been using my mcbook pro for like a year now with no problem but last Monday, I started having concerns about my keychain access.. every time i open the mac it asks for my keychain password.. what can i do?

    Hello there!
    I am a new Mc Bok Pro user and had been using my mac since Sept, 2012 with no problem. Just recently however, I have been experiencing a Keychain access problem. Specifically, whenever I open the mac, it asks for my keychain password... Can I restore my mac to its condition before Jan. 18, 2014? What should I do?
    Thanks everyone!
    Georgem

    This is only for Local Items key chain not Login Keychain.
    “Local Items” keychain prompt?
    Try this.
    https://support.apple.com/kb/TS5362

  • When i login with microsoft account cannot access with administrative share c$

    i have a problem when i login to windows with microsoft account cannot access any network computer with administrative sharing c$,d$ with windows 8.1 
    but when i login with local account can access
    and some people tell  me create key in regedit t fix it 
    after enter user name and password show this error 
    and i apply your instruction  and not fix until now
    note:
     my Machine windows 8.1 if another machine in network windows 7 can access a hidden share if machine in network windows 8.1 show this message in image 2 
    but if i login with local user can i access all machine hidden share network windows 7 and 8.1

    yes this computer i want to access  name poland2-work and have two users 
    first :administrator
    second : poland 2

Maybe you are looking for