PHP中怎么實(shí)現(xiàn)全站權(quán)限驗(yàn)證,很多新手對(duì)此不是很清楚,為了幫助大家解決這個(gè)難題,下面小編將為大家詳細(xì)講解,有這方面需求的人可以來學(xué)習(xí)下,希望你能有所收獲。
讓客戶滿意是我們工作的目標(biāo),不斷超越客戶的期望值來自于我們對(duì)這個(gè)行業(yè)的熱愛。我們立志把好的技術(shù)通過有效、簡單的方式提供給客戶,將通過不懈努力成為客戶在信息化領(lǐng)域值得信任、有價(jià)值的長期合作伙伴,公司提供的服務(wù)項(xiàng)目有:域名注冊(cè)、虛擬主機(jī)、營銷軟件、網(wǎng)站建設(shè)、貴港網(wǎng)站維護(hù)、網(wǎng)站推廣。
PHP全站權(quán)限驗(yàn)證代碼示例:
< html>
< head>< title>e
< /title>
< /head>
< body>
< form action="login.php"
method="POST" >
用戶:
< input type="text"
name="username">
< br>
密碼:
< input type="password"
name="password">
< input type ="Submit"
value ="確定">
< input type ="reset"
value ="取消">
< /form>
< /body>
< /html>
----------------conn.php--------------------------
< ?php
$host='127.0.0.1';
$MySQL_user='root';
$mysql_password='qeephp';
$mydb='learn';
$link = mysql_connect($host,
$mysql_user , $mysql_password)
or die("無法連接數(shù)據(jù)庫: "
. mysql_error());
mysql_select_db($mydb);
?>
----------------------------login.php------------------
< ?
$username=$_POST['username'];
$password=$_POST['password'];
if ($username==""){
echo "< script language='javascript'>
alert('非法操作!'); location.href=
'index.php'; < /script>";exit;
}
require_once("conn.php");
$sql="SELECT * FROM admin where
username='$username'";$result=mysql_query($sql);
$row=mysql_fetch_array($result);
if ($row['username']==""){
echo "< script language='javascript'>
alert('用戶名有誤!'); location.href=
'index.php'; < /script>";exit;
}else if ($row['password']!=$password){
echo "< script language='javascript'>
alert('密碼有誤!'); location.href='index
.php'; < /script>";echo "密碼有誤";
exit;
}else{
session_start();
$_SESSION['user']=$username;
echo "< script language='javascript'>
alert('登陸成功!'); location.href=
'list.php'; < /script>";}
?>
------------------check.php--------------------
< ?
session_start();
if(! isset($_SESSION['user']))
{
echo "< script language='javascript'>
alert('非法操作!'); location.href=
'index.php'; < /script>";exit;
}else{
echo "歡迎".$_SESSION['user']
."登錄系統(tǒng)";}
?>
---------------------list.php-----------------
< ?
include 'check.php';
?>
< html>
< head>
< script type="text/javascript"
src="player/swfobject.js">< /script>< /head>
< body>
< h4>單個(gè)文件播放:< /h4>
< p id="player1">< a href="
http://www.macromedia.com/go/
getflashplayer">獲取播放器< /a> 觀看電影< /p>< script type="text/javascript">
var s1 = new SWFObject("player/
flvplayer.swf","single","300","170","7");s1.addParam("allowfullscreen","true");
s1.addVariable("file","player/ad.flv");
s1.addVariable("image","player/preview.jpg");
s1.addVariable("width","300");
s1.addVariable("height","170");
s1.write("player1");
< /script>
< h4>playlist file, with different
colors:< /h4>< p id="player2">< a href="http:
//www.macromedia.com/go/getflashplayer">
Get the Flash Player< /a> to see this player.< /p>< script type="text/javascript">
var s2 = new SWFObject("player/flvplayer
.swf","playlist","300","312","7");s2.addParam("allowfullscreen","true");
s2.addVariable("file","player/playlist.xml");
s2.addVariable("displayheight","200");
s2.addVariable("backcolor","0x000000");
s2.addVariable("frontcolor","0xCCCCCC");
s2.addVariable("lightcolor","0x557722");
s2.addVariable("width","300");
s2.addVariable("height","312");
s2.write("player2");
< /script>
< /body>
< /html>
--------------------logout.php-------------------------
< ?php unset($_SESSION['user']); unset($_SESSION['password']); echo "注銷成功"; ?>
看完上述內(nèi)容是否對(duì)您有幫助呢?如果還想對(duì)相關(guān)知識(shí)有進(jìn)一步的了解或閱讀更多相關(guān)文章,請(qǐng)關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝您對(duì)創(chuàng)新互聯(lián)的支持。
分享標(biāo)題:PHP中怎么實(shí)現(xiàn)全站權(quán)限驗(yàn)證
轉(zhuǎn)載注明:http://jinyejixie.com/article6/jopsog.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計(jì)、網(wǎng)站收錄、品牌網(wǎng)站制作、電子商務(wù)、外貿(mào)建站、企業(yè)建站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)