限制区域内的用户级别触发不同内容[关闭]

I am creating a login system and the idea I have is when someone logins , an if statement will check the user level, and for each level it will run a different code , something like

if ( row['userLevel']== 2 ) {

// here comes the whole page


};
if ( row['userLevel']==1 ) {


// here comes the whole page in a different way

}

or should I use only one page , and evrytime I need to load something specific to a level I use the if statment

</div>

That depends how different your pages are surely? If they are completely different, I would do it as you are currently doing it. If they are almost the same then I would use one page and change the content where necessary.

Doesn't that depend on your aims? If there are two different pages, i.e. an admin page, it may be useful to detect early the permissions of an user. Otherwise, you will produce duplicate code.

I agree with the other comments.

And i think this way is better

// 0 = User
// 1 = Moderator
// 2 = Supermod
// 3 = Admin

    if ( row['userLevel'] >= 1 ) { 
    echo "This page can see for: mod, supermod and Admin.";
     }
    if ( row['userLevel'] >= 3 ) { 
    echo "This page can see for: Admin.";
     }