php 审核管理
Posted 哔哩哔哩干杯
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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> <script src="jquery-1.11.2.min.js"></script> <?php include("DBDA.php"); $db = new DBDA(); //查询用户表,查出所有数据 $suser = "select * from users"; $auser = $db->Query($suser); //查询角色表,查出所有数据 $sjuese = "select * from juese"; $ajuese = $db->Query($sjuese); ?> </head> <body> <h1>权限管理:用户对应角色管理</h1> <div> 请选择用户: <select id="user"> <?php foreach($auser as $v) { echo "<option value=\'{$v[0]}\'>{$v[2]}</option>"; } ?> </select> </div> <br /> <div> 请选择相应的角色: <?php foreach($ajuese as $v) { echo "<input type=\'checkbox\' class=\'juese\' value=\'{$v[0]}\' /> {$v[1]} "; } ?> </div> <br /> <div><input type="button" value="保存" id="btn" /></div> </body> <script type="text/javascript"> $(document).ready(function(e) { JSChecked(); $("#btn").click(function(){ //取人员的选中值 var uid = $("#user").val(); //取复选框的所有选中值 var ck = $(".juese"); var js = ""; for(var i=0;i<ck.length;i++) { if(ck[i].checked) { js = js+ck.eq(i).val()+"|"; } } js = js.substr(0,js.length-1); $.ajax({ url:"quanxianchuli.php", data:{uid:uid,js:js}, type:"POST", dataType:"TEXT", success: function(data){ if(data.trim()=="OK") { alert("添加成功!"); } else { alert("添加失败!"); } } }); }) $("#user").change(function(){ JSChecked(); }) }); function JSChecked() { //取选中的用户名 var uid = $("#user").val(); $.ajax({ url:"quanxianchuli2.php", data:{uid:uid}, type:"POST", dataType:"TEXT", success: function(data){ //清空原有选中信息 $(".juese").prop("checked",false); //找到该人员对应的角色代号数组 var attr = data.split("|"); //找到所有的checkbox var ck = $(".juese"); //遍历每个复选框,设置选中 for(var i=0; i<ck.length;i++) { var dh = ck.eq(i).val(); //$.inArray(dh,attr) 判断元素是否在数组中,如果在返回所在位置的索引,如果不在返回-1 if($.inArray(dh,attr)>=0) { ck.eq(i).prop("checked",true); } } } }); } </script> </html>
<?php include("DBDA.php"); $db = new DBDA(); $uid = $_POST["uid"]; $juese = $_POST["js"]; //将传入的角色字符串拆分为数组 $attr = explode("|",$juese); //删除原数据 $sdel = "delete from userinjuese where userid=\'{$uid}\'"; $db->Query($sdel,0); //循环添加数据 foreach($attr as $v) { $sql = "insert into userinjuese values(\'\',\'{$uid}\',\'{$v}\')"; $db->Query($sql,0); } echo "OK";
<?php include("DBDA.php"); $db = new DBDA(); $uid = $_POST["uid"]; $sql = "select jueseid from userinjuese where userid=\'{$uid}\'"; echo $db->StrQuery($sql);
登陆界面
<!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>
</head>
<body>
<h1>登录页面</h1>
<form action="quanxianchuli3.php" method="post">
<div>用户名:<input type="text" name="uid" /></div>
<div>密码:<input type="password" name="pwd" /></div>
<div><input type="submit" value="登录" /></div>
</form>
</body>
</html>
<?php session_start(); include("DBDA.php"); $db = new DBDA(); $uid = $_POST["uid"]; $pwd = $_POST["pwd"]; $sql = "select pwd from users where uid=\'{$uid}\'"; $mima = $db->StrQuery($sql); if($pwd==$mima && $uid != "" && $pwd != "") { $_SESSION["uid"]=$uid; header("location:quanxian3.php"); } else { echo "登录失败!"; }
主页面
<!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 type="text/css"> *{ margin:0px auto; padding:0xp} #menu{ width:90%; height:35px} .list{ width:120px; height:35px; margin-left:5px; background-color:#60C; color:white; font-family:微软雅黑; font-size:16px; font-weight:bold; text-align:center; line-height:35px; vertical-align:middle; float:left} </style> </head> <?php session_start(); include("DBDA.php"); $db = new DBDA(); if(empty($_SESSION["uid"])) { header("location:quanxian2.php"); exit; } $uid = $_SESSION["uid"]; //根据用户名查用户对应角色表,找到相应的角色代号 $sjs = "select jueseid from userinjuese where userid=\'{$uid}\'"; $attr = $db->Query($sjs); //根据角色代号查找功能 $gn = array(); //存放功能的二维数组 $onegn = array();//存放功能的一维数组 foreach($attr as $v) { $sgn = "select ruleid from juesewithrules where jueseid=\'{$v[0]}\'"; $agn = $db->Query($sgn); $gn = array_merge($gn,$agn); } //将二维数组转化为一维数组 foreach($gn as $v) { $onegn[] = $v[0]; } //对功能的一维数组进行去重 $onegn = array_unique($onegn); ?> <body> <h1>主页面</h1> <div id="menu"> <?php foreach($onegn as $v) { $sname = "select name from rules where code=\'{$v}\'"; $name = $db->StrQuery($sname); echo "<div class=\'list\'>{$name}</div>"; } ?> </div> </body> </html>
以上是关于php 审核管理的主要内容,如果未能解决你的问题,请参考以下文章