1 2 Previous Next 23 Replies Latest reply: Apr 9, 2012 6:36 AM by Tasneem RSS

    login and change message location

    Tasneem
      Hi all,
      I want to display an error msg when the user enters user name or pwd incorrect, and would like to change the location of the error msg on the screen , here is the code::


      declare
           cursor c1 is select user_name, user_password from Users;
           c1_user_name Users.user_name%type;
           c1_user_password Users.user_password%type;
           
      begin
      :global.count:=0;
      open c1;
      first_record;
      loop
      fetch c1 into c1_user_name,c1_user_password;
      exit when c1%notfound;

      if :user_name= c1_user_name and :user_password= c1_user_password then
           
      new_form('MAIN_MENU.fmx');

      else
           
           begin
           
                message('the user name or password is incorrect');
                message('the user name or password is incorrect');
                :global.count := nvl(:global.count,0)+1; --counting # of login trials
                
                                    
           end;
           
                     
           end if;
           

      if :global.count =3 then
                     begin
      clear_block ('USERS.fmx');
           exit_form(NO_COMMIT,NO_VALIDATE);
           end;
      end if;


      end loop;

      close c1;

      end;


      1) Is it correct?? because it doesn't close the form when count reaches 3
      2) how to change the location of the msg because it is not displayed completely???

      Thank u,
      Tasneem
        • 1. Re: login and change message location
          Sarah
          hi

          sorry to say, i did not understand ur logic.What do you want to achieve?

          are you trying to create your own login screen?


          sarah
          • 2. Re: login and change message location
            Tasneem
            yes.. I would like to create login screen
            • 3. Re: login and change message location
              Sarah
              hi

              try something like this.

              create a table.

              example:-
              create table userss(usrid varchar2(10),
              password varchar2(10));
              
              insert into userss(usrid,password)
              values('sarah','sarah');
              create a when-button-pressed trigger.
              declare
              cursor c1 is select usrid, password from Userss;
              c1_usrid Users.usrid%type;
              c1_password Users.password%type;
              
              
              begin
              :global.count:=0;
              open c1;
              first_record;
              loop
              fetch c1 into c1_usrid,c1_password;
              exit when c1%notfound;
              
              
              if :usrid= c1_usrid and :password= c1_password then 
              
              
              call_form('main_menu.fmx');
              
              
              else
              
              
              begin 
              
              
              message('the user name or password is incorrect');
              message('the user name or password is incorrect');
              :global.count := nvl(:global.count,0)+1; --counting # of login trials
              
              
              
              end; 
              
              
              
              end if; 
              
              
              
              if :global.count =3 then 
              begin 
              clear_block ('USERS.fmx');
              exit_form(NO_COMMIT,NO_VALIDATE);
              end; 
              end if; 
              
              
              
              end loop;
              
              close c1;
              
              
              end;
              hope this helps you.
              note not tested.
              sarah
              • 4. Re: login and change message location
                Tasneem
                Ok. but what is the difference between this code and my code???????
                • 5. Re: login and change message location
                  437800
                  reason seems this ..

                  clear_block ('USERS.fmx');


                  is there any block with name like this. try correcting this and ur ready to go
                  • 6. Re: login and change message location
                    Tasneem
                    No it is not the problem,,,

                    And how to change the location of the message??????
                    • 7. Re: login and change message location
                      Sarah
                      did you store user name and password in database?

                      new_form will ask for commiting so i used call_form instead of new_form.

                      u r using else in u r code.if password and username are correct then it will call the form otherwise it will ask for pass and user name.
                      if :usrid= c1_usrid and :password= c1_password then 
                      
                      
                      call_form('your_fmx');
                      
                      
                      else............
                      why you are using the following?
                      if :global.count =3 then 
                      begin 
                      clear_block ('USERS.fmx');
                      exit_form(NO_COMMIT,NO_VALIDATE);
                      end; 
                      end if; 
                      can you explain it?
                      sarah
                      • 8. Re: login and change message location
                        Tasneem
                        in order to exit the form when the user entered wrong user or password for 3 times
                        • 9. Re: login and change message location
                          Sarah
                          try something like this in u r last code.
                            
                          if TO_NUMBER(:global.count) >=3
                          then
                              clear_message;
                              message ( 'Maximum login attempts exceeded. The application will be closed.' );
                          ---------------------------
                          end if;
                          • 10. Re: login and change message location
                            Andreas Weiden
                            Your code is not correct. Firstly, you loop over all records in you table and compare each record with the entered username and password. So, if there are 100records in your table you will get 100 times the error that username and password are not correct. You shoule add a WHERE-condition to your query and strict to the data matching the entered values.

                            But... are you sure you want to store the users passwords in cleartext in a table. Thats a big security hole in your application. You should Hash the password first and then only store the hash in your table. Search google for it, there are lts of examples.
                            • 11. Re: login and change message location
                              Sarah
                              hi

                              actually a login screen,contain 3 items:
                              user name,
                              password,
                              sid
                              ====
                              and 2 buttons:
                              login,
                              cancel.


                              but you have only two so we are not able to help you very well.

                              create three items and try.


                              sarah
                              • 12. Re: login and change message location
                                Tasneem
                                Ok. but how not to loop through all records in the table??? what is the where clause to use???
                                • 13. Re: login and change message location
                                  Amatu Allah Neveen Ebrahim
                                  Hi
                                  what is the where clause to use??
                                  The cursor is always used in multi-row query and declared in the declaration part of ur code as if for now u asked the system of Oracle to reserve u an unnamed work area that stores processing information.
                                  A cursor lets you name the work area, access the information, and process the rows individually.

                                  Pls follow the giving code
                                  Declare
                                  CURSOR c1 IS SELECT user_name, user_password 
                                  FROM Users
                                  WHERE user_name =:user_name
                                  AND  user_password = :user_password ;
                                  .....
                                  Hope this helps...

                                  Regards,

                                  Amatu Allah
                                  • 14. Re: login and change message location
                                    Sarah
                                    hi

                                    try something like this.

                                    create a block with three items block name is login_block and items(non-db items)
                                    names are.

                                    USERNAME
                                    PASS_WORD
                                    CONNECT_STRING

                                    and table is.
                                    CREATE TABLE USERS_NAME (
                                    USER_NAME VARCHAR2(100),
                                    USER_PASSWORD VARCHAR2(20),
                                    CONN_STRING VARCHAR2(5));
                                    create a user test and password test and then
                                    grant select on all tables to test.

                                    when-button-pressed trigger code.
                                    declare
                                         l_pw_expired varchar2(1) default 'N';
                                         Num_Temp NUMBER := 0;
                                    begin
                                         default_value ( 0, 'global.sarah' );
                                         if
                                              :LOGIN_BLOCK.USERNAME is null OR :LOGIN_BLOCK.PASS_WORD is null
                                         then
                                           message( 'Please enter username and password to login.' );
                                           message( ' ' );
                                           go_item( 'LOGIN_BLOCK.USERNAME' );
                                           return;
                                         end if;
                                    :global.sarah := to_number ( :global.sarah ) + 1;
                                    
                                           SELECT COUNT(USER_NAME) INTO Num_Temp FROM USERS_NAME WHERE UPPER(USER_NAME) = UPPER(:LOGIN_BLOCK.USERNAME)
                                            AND UPPER(USER_PASSWORD) = UPPER(:LOGIN_BLOCK.PASS_WORD);
                                            --AND UPPER(CONNECT_STRING)= UPPER(:LOGIN_BLOCK.CONNECT_STRING);
                                          IF Num_Temp = 0 THEN
                                                
                                              message ( ' ' || dbms_error_text );
                                    message ( ' ' );
                                      if
                                           TO_NUMBER(:global.sarah) >=3
                                      then
                                        clear_message;
                                        message ( 'Maximum login attempts exceeded. The application will be closed.' );
                                    -----------------------------------------------------------------------------------------------
                                    
                                        LOGON('test','test@orcl');-- create username test pass test
                                       
                                              FORMS_DDL('ALTER USER ' || :LOGIN_BLOCK.USERNAME|| ' ACCOUNT LOCK');
                                        
                                        exit_form ( no_validate );
                                      end if;
                                      :login_block.pass_word := null;
                                      go_item ( 'login_block.pass_word' );
                                      raise form_trigger_failure;
                                    end if;
                                    
                                         LOGOUT;  
                                         if
                                              :LOGIN_BLOCK.CONNECT_STRING is null
                                         then
                                         
                                           logon( :LOGIN_BLOCK.USERNAME, :LOGIN_BLOCK.PASS_WORD, FALSE );
                                         else
                                           logon( :LOGIN_BLOCK.USERNAME, :LOGIN_BLOCK.PASS_WORD ||'@'|| :LOGIN_BLOCK.CONNECT_STRING, FALSE );
                                         end if;
                                    
                                    if
                                         NOT form_success
                                    then
                                      message ( dbms_error_text );
                                      message ( ' ' );
                                      if
                                           TO_NUMBER(:global.sarah) >= 3
                                      then
                                        clear_message;
                                        message ( 'Maximum login attempts exceeded. The application will be closed.' );
                                    ------------------------------------------------------------------------------------------------------------------------------
                                    
                                      LOGON('test', 'test@'|| :LOGIN_BLOCK.CONNECT_STRING);
                                      --|| :LOGIN_BLOCK.CONNECT_STRING     
                                              FORMS_DDL('ALTER USER ' || :LOGIN_BLOCK.USERNAME|| ' ACCOUNT LOCK');-- HERE ACCOUNT WILL BE LOCKED IF YOU TRY MORE THAN THREE TIMES.
                                        
                                        exit_form ( no_validate );
                                      end if;
                                      :login_block.pass_word := null;
                                      go_item ( 'login_block.pass_word' );
                                      raise form_trigger_failure;
                                    end if;
                                    call_form('.....');
                                    --OR
                                    New_form('....');
                                    end;
                                    on-logon trigger form level.
                                    begin
                                    if
                                         :login_block.username is null
                                    then
                                    
                                    LOGON('TEST','TEST@orcl');
                                    
                                      return;
                                    else
                                      logon( get_application_property(USERNAME), 
                                             get_application_property(PASSWORD)||'@'||get_application_property(CONNECT_STRING), FALSE);
                                      if
                                           form_failure
                                      then
                                        raise form_trigger_failure;
                                      end if;
                                    end if;
                                    end;
                                    hope this helps u.

                                    sarah
                                    1 2 Previous Next