The previous article is about the Administrator page, can complete the role of the user modification and save, here is a user interface, the user through the login, display its corresponding function interface.
1. Login page (using AJAX, you can also use PHP form submission method)
1 <!DOCTYPE HTML Public "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd ">2 <HTMLxmlns= "http://www.w3.org/1999/xhtml">3 <Head>4 <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8" />5 <Scripttype= "Text/javascript"src=".. /jquery-1.11.12.min.js "></Script>6 <title>Login interface</title>7 </Head>8 9 <Body>Ten <Div>User name:<inputtype= "text"name= "UID"ID= "UID"/></Div> One <Div>Password:<inputtype= "Password"name= "pwd"ID= "pwd" /></Div> A <ButtonID= "Login">Landing</Button> - </Body> - <Script> the $("#login"). Click (function(){ - varUID=$("#uid"). Val (); - varpwd=$("#pwd"). Val (); - $.ajax ({ + URL:"login.php", - Data:{ids:uid,password:pwd}, + Type:"POST", A DataType:"TEXT", at Success:function(data) { - if(Data.trim ()=="OK"){ - Alert ("Landing Success"); - window.location.href="zhuyemian.php"; - } - Else{ in - Alert ("incorrect account or password"); to } + - } the * $ Panax Notoginseng }) - the + A }) the + - </Script> $ </HTML>
Login Processing page (save user with session)
<? Phpsession_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"; } ?>
Main Page code
1 <!DOCTYPE HTML Public "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd ">2 <HTMLxmlns= "http://www.w3.org/1999/xhtml">3 <Head>4 <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8" />5 <title>Main Page</title>6 <style>7 . List{width:100px;8 Height:30px;9 Border:1px #0000CC Solid;Ten Background-color:#36C;} One A - </style> - </Head> the <?PHP - session_start (); Open Session - $uid = ""; - if (Empty ($_session["UID"]))//Determine if the SESSION exists + {Header ("location:denglu.php"); Skip to landing page if not present - } + else{ A $uid =$_session["UID"]; The $UID variable is given the presence at } - require ". /database.class.php "; - $db =new DataBase (); - $sql = "SELECT *" from the rules where code in (select distinct RuleId from Juesewithrules where Jueseid in (select Jueseid fr Om Userinjuese where userid= ' {$uid} ') ';//Sub-query Ah, according to the relationship between the session user name and table to find the corresponding function - $arr = $db->query ($sql); - foreach ($arr as $v) in { - echo "<div code= ' {$v [0]} ' class= ' list ' > $v [1]</div>";//Traversal input div element display function to + } - the * $ ?>Panax Notoginseng - <Body> the </Body> + </HTML>
Look at the effect
The corresponding Main page
The corresponding Main page
PHP Rights Management (user interface Implementation)