Displaying username in the Menu Header

Á

Álvaro Moura

Last updated on Jul 6, 2026

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 module1. 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.