Suggestion for Login with Access Levels php mysql

Asked

Viewed 113 times

0

I need a hint as to how you would implement a login system via php and mysql with access levels, example:

I have a database Mysql with is registered users, this in turn has several different access levels, currently 12 in total, and two of them are for administrators and another for partners of the company, the rest goes from basic user registration to defining the plans they have, follows the list of levels you have today.

  1. Cadastro Básico
  2. Registration Personal Data
  3. Cadastro Completo
  4. Choice of Plan
  5. Monthly Plan
  6. Annual plan
  7. Premium Plan
  8. Monthly Payment Due
  9. Blocked User
  10. Monthly fee 10 days to win
  11. Partners
  12. Administrators

Currently I record or update in the database the user information as it modifies your registration or your plan, for levels of administrators and partners is simpler because it is the company that makes the registration soon they change the level of access.

The issue is with the pages that these users have access to, each level will give access to certain pages, and my debt is how to create safely and that does not slow down the system, a relationship that the system sees that the user that is at the level Monthly Plan has access for example to page 1,2,3,4, already who has the Premium Plan has access to pages 1,2,3,5,5,9,7,9,10, administrators have full access, partner access everything except the pages of administrators, and so on, as I update the status of it in the bank, the system see that is now user Premium Plan for example and already releases in the menu the links that are this plan.

I thought I’d see switch case, but I don’t know if it would slow down the system, something like that

$perfil             = "?p=perfil";
$dashboard          = "?p=dash";
$operacionalDia     = "?p=operDia";

if (isset($urlAtual)) {
        switch ($urlAtual) {
            case 'perfil':
                $nomePagina = "Perfil";
                $urlPagina  = "perfil.php";
                break;
            case 'dash':
                $nomePagina = "Dashboard";
                $urlPagina  = "dashboard.php";
                break;
        default:
                $nomePagina = "Dashboard";
                $urlPagina  = "dashboard.php";
}

What do you say?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.