亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Administrator login for developing simple guestbook in PHP

We will use jquery in this section. First we need to introduce a jquery library, as follows:

<script type="text/javascript" src="http://libs.baidu.com/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
     寫(xiě)入代碼
</script>

Here we introduce the jquery library: "http://libs.baidu.com/jquery/ 1.7.2/jquery.min.js”

The administrator login uses click on the <input> tag to display and hide the login window.

Use the jquery toggle() method to switch the visible state of an element.

If the selected elements are visible, then hide these elements. If the selected elements are hidden, then display these elements.

Add an id="login_show_button

<div class="login_button"><a href="#" id="login_show_button">管理員登錄</a></div>

to the <a> tag when logged in by the administrator

<script type="text/javascript">
$(document).ready(function() {
      $("#login_show_button").toggle(function(){
         $("#login_form").show(100);
         return false;
      },function(){
         $("#login_form").hide(100);
         return false;
      });
</script>

Then use the following jquery code to achieve the effect

<?php
class User{
   static public function validate($username,$password){  // static public 聲明公共變量
      if("admin"==$username && "12345"==$password){
         return true;
      }
      else 
         return false;
   }
}
?>

show() representation Show, hide() means hide.

Administrator login we set a public variable User class

<?php
class Authority{
   static public  function check_insert(){  //聲明公共變量
      //檢查是否具有添加留言權(quán)限
      return true;
   } 
   static public  function check_delete(){
      //檢查是否具有delete權(quán)限
      if(isset($_SESSION["username"]) && $_SESSION["username"]=="admin")
         return true;
      else 
         return false;
   }
}
?>

Set the administrator login name to: admin, and set the password to: 12345.

If the login name and password are entered correctly, you can enter the page to operate.

An authority class is also set up to check whether there is administrator permission.

Judge the input login. Whether the name and password match the login name and password saved in the session.

rrreee###Encapsulate the above two classes into an authority.class.php file for later call when we implement the function.
Continuing Learning
||
<?php class Authority{ static public function check_insert(){ //聲明公共變量 //檢查是否具有添加留言權(quán)限 return true; } static public function check_delete(){ //檢查是否具有delete權(quán)限 if(isset($_SESSION["username"]) && $_SESSION["username"]=="admin") return true; else return false; } } ?> <?php class User{ static public function validate($username,$password){ // static public 聲明公共變量 if("admin"==$username && "12345"==$password){ return true; } else return false; } } ?>
submitReset Code