Login Page<form action= "loginchuli.php" method= "POST" > <div> user name: <input type= "text" name= "UID"/></div> <div> Password: <input type= "text" name= "pwd"/></div> <input type= "Submit" value= "Login"/></form> ;Loginchuli Page<?PHPSession_Start();$uid=$_post["UID"];$pwd=$_post["PWD"];include(".. /dbda.php ");$db=NewDbda ();$sql= "SELECT count (*) from Users where uid= ' {$uid} ' and Pwd = ' {$pwd}‘";$z=$db->strquery ($sql);if($z= = 1){ $_session["UID"] =$uid; Header("location:main.php");}Else{ Header("location:login.php");}
Main Page Face
<?PHPSession_Start();if(Empty($_session["UID"])){ Header("location:login.php"); Exit;}$uid=$_session["UID"];include(".. /dbda.php ");$db=NewDbda ();><meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/><title> Untitled document </title><style type=" text/css ">*{margin:0px auto; padding:0px}#menu{width:100%; Height:40px; }.cd{Width:100px; Height:40px; Background-color:#60C;ColorWhite ; Font-size:18px; Text-align:Center; Line-height:40px; Vertical-align:Middle; float:Left ; }. CD:hover{Background-color:#F33;Cursorpointer; }</STYLE></HEAD><BODY><BR/><center>Echo $uid;? ></a><br/><div id= "menu" > <divclass= "CD" > Rights Management </div> <?PHP//find the corresponding role code according to the user name $sjs= "Select Jueseid from Userinjuese where UserId = ' {$uid}‘ "; $ajs=$db->query ($sjs); //find the corresponding function according to the character code $all=Array();//store all of the user's function codes foreach($ajs as $vjs) { $SGN= "Select RuleId from juesewithrules where Jueseid = ' {$vjs[0]} ' "; $agn=$db->query ($SGN); foreach($agn as $VGN) { Array_push($all,$VGN[0]); } } $all=Array_unique($all); //Show Menu foreach($all as $vall) { $SN= "Select Name from Rules where Code = ' {$vall}‘"; $name=$db->strquery ($SN); Echo"<div class= ' CD ' >{$name}</div> "; } ?> </div>
Guanli page
Please select User:<select id= "user" > <?PHPinclude(".. /dbda.php "); $db=NewDbda (); $sql= "SELECT * FROM Users"; $attr=$db->query ($sql); foreach($attr as $v) { Echo"<option value= ' {$v[0]} ' >{$v[2]} </option> "; } ?> </select></div><br/><div> <div> Please select role:</div> <br/> <div& Gt <?PHP$sqljs= "SELECT * FROM Juese"; $attrjs=$db->query ($sqljs); foreach($attrjs as $v) { Echo"<input class= ' js ' type= ' checkbox ' value= ' {$v[0]} ' /> {$v[1]} "; } ?> </div> </div><br/><div> <input type= "button" value= "OK" id= "BTN"/></div> ; </body><script type= "Text/javascript" >$ (document). Ready (function(e) {Showjuese (); $("#user"). Change (function() {Showjuese (); }) functionShowjuese () {varUID = $ ("#user").Val (); $.Ajax ({URL: "Seljuese.php",Data: {Uid:uid},type: "POST",DataType: "TEXT",Success:function(data) {varShuju = data.Split("|"); varCK = $ (". js")); CK. Prop ("Checked",false); for(vari=0;i<ck.length;i++) { varv = ck.eq (i).Val (); if($.inarray (V,shuju) >=0) {ck. EQ (i). Prop ("Checked",true); } } } }); } $("#btn"). Click (function(){ varUID = $ ("#user").Val (); varCK = $ (". js")); varstr = ""; for(vari=0;i<ck.length;i++) { if(Ck.eq (i). Prop ("checked")) ) {str= Str+ck.eq (i). Val () + "|"; }} str= str.substr(0,str.length-1); $.Ajax ({URL: "Add.php",Data: {UID:UID,JUESE:STR},type: "POST",DataType: "TEXT",Success:function(data) {if(Data.Trim() = = "OK") {alert ("Added successfully! "); } Else{alert ("Add failed! "); } } }); }) });</script>
Add page
<?PHPinclude(".. /dbda.php ");$db=NewDbda ();$uid=$_post["UID"];$js=$_post["Juese"];$juse=Explode("|",$js);$bs=true;//empty all roles that the user has$sqldel= "Delete from Userinjuese where UserId = ' {$uid}‘ ";if(!$db->query ($sqldel, 0)){ $bs=$bs&&false;}//Add role Informationforeach($juse as $v){ $sql= "INSERT into Userinjuese values ('", ' {$uid}‘,‘{$v}‘)"; if(!$db->query ($sql, 0)) { $bs=$bs&&false; }}if($bs){ Echo"OK";}Else{ Echo"NO";}
Seljuese page
<? PHP include (".. /dbda.php "); $db New Dbda (); $uid $_post ["UID"]; $sql = "Select Jueseid from Userinjuese where UserId = ' {$uid} '"; Echo $db->strquery ($sql);
PHP Rights Management