78th Day class PHP permissions control

Source: Internet
Author: User

Shenfenguanli

<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/><script src=". /zz-function/js/$Jquery. js "></script><title> Untitled document </title><br><div> Please select User:&nbsp;<select><?PHPinclude".. /zz-function/class/uniondatabase.php ";$db=Newuniondatabase ();$sql= "Select Zhanghu,mingzi from Yonghu";$result=$db->query ($sql);foreach($result  as $i){    Echo"<option value= '$i[0] >$i[1]</option> ";}?></select></div><div><br>Please select a job title:<?PHP$sql= "SELECT * FROM Juese";$result=$db->query ($sql);foreach($result  as $i){    Echo"<input class= ' Juese ' type= ' checkbox ' value= '$i[0] >$i[1] "." &nbsp; ";}? ></div><br/><div><input id= "Tijiao" type= "button" value= "OK"/></div><script Type= "Text/javascript" >$ (document). Ready (function() {Juese (); $("Select"). Change (function() {Juese ();    }); $(' #TiJiao '). Click (function() {Juesetijiao (); })});functionJuese () {varzhanghu=$ (' select ').Val (); $.Ajax ({URL: "Juese.php",Data: {zhanghu:zhanghu,x:1},type: "POST",DataType: "JSON",Success:function(e) {varjuese=$ ('. Juese '); Juese. Prop (' checked ',false)             for(vari=0;i<juese.length;i++)            {                varJ=juese.eq (i).Val ();  for(varx=1;x<e.length;x++)                {                    if(e[i][0]==j) {Juese. EQ (i). Prop (' checked ',true); }                }            }        }    });}functionJuesetijiao () {varzhanghu=$ (' select ').Val (); varjuesex=$ ('. Juese '); varJuese= ";  for(vari=0;i<juesex.length;i++ )    {        if(Juesex.eq (i). Prop (' checked '))) Juese+=juesex.eq (i). Val () + "|"; } Juese=juese.substr(0,juese.length-1); $.Ajax ({URL: "Juese.php",Data: {Zhanghu:zhanghu,juese:juese,x:2},type: "POST",DataType: "TEXT",Success:function(e) {alert (e)}});</script>

juese.php

<?PHPinclude".. /zz-function/class/uniondatabase.php ";$db=Newuniondatabase ();$x=$_post[' X '];if($x==1){    $ZhangHu=$_post[' Zhanghu ']; $sql= "Select Juese from Yonghuinjuese where zhanghu= '$ZhangHu‘"; Echo $db->queryjson ($sql);}Else if($x==2){    $ZhangHu=$_post[' Zhanghu ']; $JueSe=$_post[' Juese ']; $sql= "Delete from Yonghuinjuese where zhanghu= '$ZhangHu‘"; $result 1=$db->query ($sql); $JueSe=Explode("|",$JueSe); foreach($JueSe  as $i)    {        $sql= "INSERT into Yonghuinjuese values (' ', '$ZhangHu‘,‘$i‘)"; $result 2=$db->query ($sql); }    if($result 1||$result 2)        Echo"Role Modification succeeded"; Else        Echo"Modify Failed"; }

dengru.php

<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/><title> Login interface </title><style>*{outline:none;} form{text-align:Center; Top:20px;} Form input{Border: 1px solid#0F0;}</style><?PHPSession_Start();if(!Empty($_post[' Submit '])){    if(Empty($_post[' Zhanghu ']) | |Empty($_post[' Mima ']))    {        Echo"<script>alert (' account or password cannot be empty ') </script>"; }    Else    {        $ZhangHu=$_post[' Zhanghu ']; $MiMa=$_post[' Mima ']; include".. /zz-function/class/uniondatabase.php "; $db=Newuniondatabase (); $sql= "SELECT count (*) from Yonghu where zhanghu= '$ZhangHu' and Mima= '$MiMa‘"; if($db-&GT;QUERYSTR ($sql) ==1)        {            $_session[' Zhanghu ']=$ZhangHu; Header(' location:main.php '); }    }}><form action= "" method= "POST" >nbsp; <input type= "button" value= "Reset"/></div><br></form>

main.php

<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/><title> main interface </title><?PHPSession_Start();if(Empty($_session[' Zhanghu '])){    Header(' location:DengRu.php ');}include".. /zz-function/class/uniondatabase.php ";$db=Newuniondatabase ();$ZhangHu=$_session[' Zhanghu '];$sql= "Select Juese from Yonghuinjuese where zhanghu= '$ZhangHu‘";$JueSe=$db->query ($sql);$QuanXian=Array();foreach($JueSe  as $i){    $sql= "Select Quanxian from Jueseinquanxian where juese= '$i[0] ' "; $result=$db->query ($sql); foreach($result  as $j)    {        Array_push($QuanXian,$j[0]); }}$QuanXian=Array_unique($QuanXian);Echo"<ul>";foreach($QuanXian  as $i){    $sql= "Select Name from Quanxian where daihao= '$i‘"; $j=$db-&GT;QUERYSTR ($sql); Echo"<li>$j</li> ";}Echo"</ul>";?>

78th Day class PHP permissions control

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.