偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

教你快速實現(xiàn)PHP全站權限驗證

開發(fā) 后端
PHP全站權限驗證對于初學PHP語言的人來說還是比較苦難的。希望通過本文介紹的內(nèi)容大家可以充分掌握PHP語言在這一方面的實現(xiàn)方法。

PHP程序員在進行網(wǎng)站開發(fā)時,通常都會遇到與權限驗證相關的問題。下面我們就為大家具體介紹有關PHP全站權限驗證的實現(xiàn)方法。#t#

PHP全站權限驗證代碼示例:

  1. < html> 
  2. < head>< title>e   
  3. < /title> 
  4. < /head> 
  5. < body> 
  6. < form action="login.php" 
    method="POST" > 

用戶:

  1. < input type="text" 
    name="username"> 
  2. < br> 

密碼:

  1. < input type="password" 
    name="password"> 
  2. < input type ="Submit"
     value ="確定"> 
  3. < input type ="reset"
     value ="取消"> 
  4. < /form> 
  5. < /body> 
  6. < /html> 

 

----------------conn.php--------------------------

  1. < ?php  
  2. $host='127.0.0.1';  
  3. $mysql_user='root';  
  4. $mysql_password='qeephp';  
  5. $mydb='learn';  
  6. $link = mysql_connect($host, 
    $mysql_user , $mysql_password)  
  7. or die("無法連接數(shù)據(jù)庫: " 
    . mysql_error());  
  8. mysql_select_db($mydb);  
  9. ?> 

 

----------------------------login.php------------------

 

  1. < ?  
  2. $username=$_POST['username'];  
  3. $password=$_POST['password'];  
  4. if ($username==""){  
  5. echo "< script language='javascript'> 
    alert('非法操作!'); 
    location.href=
    'index.php'< /script>";  
  6. exit;  
  7. }  
  8. require_once("conn.php");  
  9. $sql="SELECT * FROM admin where
     username='$username'"
    ;  
  10. $result=mysql_query($sql);  
  11. $row=mysql_fetch_array($result);  
  12. if ($row['username']==""){  
  13. echo "< script language='javascript'> 
    alert('用戶名有誤!'); 
    location.href=
    'index.php'< /script>";  
  14. exit;  
  15. }else if ($row['password']!=$password){  
  16. echo "< script language='javascript'> 
    alert('密碼有誤!'); 
    location.href='index
    .php'
    < /script>";  
  17. echo "密碼有誤";  
  18. exit;  
  19. }else{  
  20. session_start();  
  21. $_SESSION['user']=$username;  
  22. echo "< script language='javascript'> 
    alert('登陸成功!'); 
    location.href=
    'list.php'< /script>";  
  23. }  
  24. ?> 

 

------------------check.php--------------------

 

  1. < ?  
  2. session_start();   
  3. if(! isset($_SESSION['user']))   
  4. {   
  5. echo "< script language='javascript'> 
    alert('非法操作!'); 
    location.href=
    'index.php'< /script>";  
  6. exit;  
  7. }else{  
  8. echo "歡迎".$_SESSION['user']
    ."登錄系統(tǒng)";   
  9. }  
  10. ?> 

 

---------------------list.php-----------------

 

  1. < ?  
  2. include 'check.php';  
  3. ?> 
  4. < html> 
  5. < head> 
  6. < script type="text/javascript" 
    src="player/swfobject.js">< /script> 
  7. < /head> 
  8. < body> 
  9. < h3>單個文件播放:< /h3> 
  10. < p id="player1">< a href="
    http://www.macromedia.com/go/
    getflashplayer"
    >獲取播放器< /a> 觀看電影< /p> 
  11. < script type="text/javascript"> 
  12. var s1 = new SWFObject("player/
    flvplayer.swf","single","300","170","7");  
  13. s1.addParam("allowfullscreen","true");  
  14. s1.addVariable("file","player/ad.flv");  
  15. s1.addVariable("image","player/preview.jpg");  
  16. s1.addVariable("width","300");  
  17. s1.addVariable("height","170");  
  18. s1.write("player1");  
  19. < /script> 
  20. < h3>playlist file, with different 
    colors:
    < /h3> 
  21. < p id="player2">< a href="http:
    //www.macromedia.com/go/getflashplayer"
    >
    Get the Flash Player< /a> to see this player.< /p> 
  22. < script type="text/javascript"> 
  23. var s2 = new SWFObject("player/flvplayer
    .swf","playlist","300","312","7");  
  24. s2.addParam("allowfullscreen","true");  
  25. s2.addVariable("file","player/playlist.xml");  
  26. s2.addVariable("displayheight","200");  
  27. s2.addVariable("backcolor","0x000000");  
  28. s2.addVariable("frontcolor","0xCCCCCC");  
  29. s2.addVariable("lightcolor","0x557722");  
  30. s2.addVariable("width","300");  
  31. s2.addVariable("height","312");  
  32. s2.write("player2");  
  33. < /script> 
  34. < /body> 
  35. < /html> 

 

--------------------logout.php-------------------------

 

  1. < ?php   
  2. unset($_SESSION['user']);   
  3. unset($_SESSION['password']);   
  4. echo "注銷成功";   
  5. ?> 

以上就是PHP全站權限驗證的具體實現(xiàn)方法。

責任編輯:曹凱 來源: 百度博客
相關推薦

2009-12-07 12:56:40

PHP文件管理

2009-11-23 10:02:22

PHP支付寶接口

2015-09-21 15:31:05

php實現(xiàn)驗證碼

2009-11-25 11:33:26

PHP驗證表單

2021-03-12 10:01:24

JavaScript 前端表單驗證

2009-12-14 16:00:32

Ruby操作Oracl

2017-11-17 19:56:46

爬蟲視頻信息數(shù)據(jù)庫

2009-12-04 15:40:53

快速升級Windows

2009-11-23 16:59:23

PHP圖形驗證碼

2015-12-29 13:32:41

2009-12-08 17:53:31

PHP const

2009-11-16 09:35:42

PHP上傳

2009-11-16 13:27:20

PHP上傳多張圖片

2011-12-29 09:47:42

2011-02-17 10:54:59

CSS3變換 簡單快捷

2009-09-08 17:45:13

Ophone Widg

2021-11-15 05:44:16

Python虛擬環(huán)境開發(fā)

2017-11-13 18:49:58

華為

2009-11-18 14:53:59

PHP Session

2009-12-03 16:24:09

WinXP搭建PHP開
點贊
收藏

51CTO技術棧公眾號