php实现人员权限管理(用户界面)

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了php实现人员权限管理(用户界面)脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

上一篇介绍的是管理员页面,能完成对用户的角色修改和保存,这里来说一下用户界面,用户通过登录显示出其对应功能界面。

1.登录页面(用的ajax,也可以用PHP表单提交方式)

<!DOCTYPE htML PubLIC "-//W3C//DTD XHTML 1.0 TransITional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html XMlns="http://www.w3.org/1999/xhtml"><head><Meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><script type="text/javascript" src="../jquery-1.11.12.min.js"></script><title>登陆界面</title></head><body><div>用户名:<input type="text" name="uid"  id="uid"/></div><div>密码:<input type="password" name="pwd" id="pwd" /></div><button id="login">登陆</button></body><script>
 $("#LOGin").click(function(){
     VAR uid=$("#uid").val();
     var pwd=$("#pwd").val();
     $.ajax({
             url:"login.PHP",             data:{ids:uid,password:pwd},             type:"POST",             dataType:"TEXT",             success: function(data){
                 if(data.trim()=="OK"){
                 alert("登陆成功");
                 window.location.href="zhuyemian.PHP";
                 }
                 else{
                     
                    alert("账号或者密码错误");
                     }
                 
                 }        
         })     
     
     })
 
 </script></html>

登录处理页面(用session存一下用户

<?PHP
session_start();
$uid=$_POST["ids"];
$pwd=$_POST["password"];
require "../DataBase.class.PHP";
$db=new DataBase();
$sql="select pwd From users where uid=‘{$uid}‘";
$arr=$db->Query($sql);
if($arr[0][0]==$pwd &&!empty($pwd)){
    
    echo "OK";
    $_SESSION["uid"]=$uid;
    }
else{
    
    echo "NO";
    }

?>

 

php实现人员权限管理(用户界面)

页面代码

  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml">
  <head>
  <Meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>主页面</title>
  <style>
  .list{ width:100px;
          height:30px;
          border:1px #0000CC solid;
         background-color:#36C;}
 
 
 </style>
 </head>
 <?PHP
 session_start();                     //开启session
 $uid="";
 if(empty($_SESSION["uid"]))            //判断一下session是否存在
 {    header("location:denglu.PHP");    //不存在就@L_406_31@到登陆页面
     }
 else{
     $uid=$_SESSION["uid"];          //存在就交给$uid变量
     }
 require "../DataBase.class.PHP";      
 $db=new DataBase();
 $sql="select * from rules where code in (select distinct ruleid from juesewithrules where jueseid in(select jueseid from userinjuese where userid=‘{$uid}‘) )";//查询啊,根据session用户名和表之间的关系找到相对应功能
 $arr=$db->Query($sql);
 foreach($arr as $v)
 {
     echo "<div code=‘{$v[0]}‘ class=‘list‘>$v[1]</div>";//遍历输入div元素显示功能
     
     }

 ?>
 
 <body>
 </body>
 </html>

看看效果

php实现人员权限管理(用户界面)

    对应的主页面 

php实现人员权限管理(用户界面)

php实现人员权限管理(用户界面)

对应的主页面

脚本宝典总结

以上是脚本宝典为你收集整理的php实现人员权限管理(用户界面)全部内容,希望文章能够帮你解决php实现人员权限管理(用户界面)所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。