douce1368 2017-03-11 17:05
浏览 73

用于管理显示内容的模板系统?

I am fairly new to PHP but have a project in mind and would like to force myself to learn as I go here. So I am using SB Admin 2 as a frontend template. I have a very basic login/logout working after having to completely scrap the old one I had to lieu of using prepared statements.

Im at the point where I am trying to decide how to hide/display content depending on the user role I specified. Does it make more sense to just create an admindashboard.php and userdashboard.php, or to hide the content in php (such as menu items in my sidebar) based on the user roll itself and have one dashboard.php. I saw someone mention a backend templating system and from my searching I see twig being pretty popular but cant find anything that really tells me this is the right track. Can someone point me to any documentation that might help with this? Thanks

  • 写回答

1条回答 默认 最新

  • doushichun9409 2017-03-11 20:25
    关注

    I have a very basic login/logout working after having to completely scrap the old one I had to lieu of using prepared statements.

    Answer: You have to simply put role column in your user table.

    Im at the point where I am trying to decide how to hide/display content depending on the user role I specified.

    Answer: use session management like for administrator use code like this <?php if(isset($_SESSION['uid'])!='' && $_SESSION['role']=='Admin'): ?>

    and write html code for your navbar here in between ending<?php endif; ?>

    for the rest use your other navbar code for non-admins hope you understand on navbar and for the page security.
    `

    <?php if(isset($_SESSION['uid'])==''){
            echo "<script>window.location='index.php';</script>";   }
        if($_SESSION['role']!='Admin'){
         echo "<script>window.location='home.php';</script>";
        }elseif($_SESSION['role']=='Employee'){
        }else{ $_SESSION['role'];}
        ?>  
    
    `
    


    this is simplest role access control. If you need to understand role based access control ask a question i will try to answer it to.

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据