Displaying username in the Menu Header

Displaying username in the Menu Header

In this article we will see how to display the name of the user logged in the system, in the header of an application menu.
This example was created using the Scritpcase native security module

1. First, select the user or login.

Access an app_login application, make the security module, in the application settings access the onValidate event.
In this event it is possible to obtain the login used by the client [usr_login].

  1. if(sc_logged_is_blocked()) { sc_error_exit(); }
  2. $slogin = sc_sql_injection({login});
  3. $spswd = sc_sql_injection(hash("md5",{pswd}));
  4. $sql = "SELECT
  5.         priv_admin,
  6.         active,
  7.         name,
  8.         email
  9.           FROM sec_users
  10.           WHERE login = $slogin
  11.         AND pswd = ".$spswd."";
  12. sc_lookup(rs, $sql);
  13. if(count({rs}) == 0)
  14. {
  15.     sc_log_add('login Fail', {lang_login_fail} . {login});
  16.     sc_logged_in_fail({login});
  17.     sc_error_message({lang_error_login});
  18. }
  19. else if({rs[0][1]} == 'Y')
  20. {
  21.     $usr_login =  {login};
  22.     $usr_priv_admin = ({rs[0][0]} == 'Y') ? TRUE : FALSE;
  23.     $usr_name = {rs[0][2]};
  24.     $usr_email  = {rs[0][3]};
  25.     sc_set_global($usr_login);
  26.     sc_set_global($usr_priv_admin);
  27.     sc_set_global($usr_name);
  28.     sc_set_global($usr_email);
  29. }
  30. else
  31. {
  32.     sc_error_message({lang_error_not_active});
  33.     sc_error_exit();
  34. }
 

2. Then access the menu application. Access the onAplicationInit event and use the code below

  1. $sql = "SELECT name FROM sec_users WHERE login = '".[]."'";
  2. sc_lookup(ds,$sql);
  3. sc_reset_global([var_glob1]);
  4. [nome] = {ds[0][0]};


3. Then go to Layout> Header & Footer and then we will assign the value of the variable [name] to one of the header variables.

 


4. Then, when accessing the login, the user name will be displayed in the menu header.


    • Related Articles

    • Crear menú de aplicación

      En este tutorial le mostraremos cómo crear una aplicación de menú. Después de crear el proyecto, se mostrará una pantalla con todas las aplicaciones disponibles para su creación. Seleccione el menú de la aplicación, ingrese el nombre y el idioma a ...
    • How to switch between themes dynamically through the Menu app

      In Scriptcase, it's possible to dynamically switch between themes by activating a Menu option, to enable that option, simply follow the steps below: Note The chosen project must have more than one theme selected, otherwise it will not be possible to ...
    • How to find my serial in Scriptcase

      Every Scriptcase installation has a registration serial, even in trial installations. In this article, see where to locate your serial within Scriptcase. 1 - Login to your Scriptcase with your username. In this example we are using the default ...
    • Creating new themes for Scriptcase

      In this article, we will show how to create and edit new themes for your applications. Scriptcase afford a complete tool for creating themes, can change the layout of buttons, all the CSS application, and the application's menu bar menu. With a ...
    • Gantt Chart

      With this tutorial you will learn to create a Gantt chart from the structure of your table in the database to generate the chart itself. In this tutorial we will use a MYSQL database for table creation. 1. With the SQL command below will create the ...