PHP程序员在进行网站开发时,通常都会遇到与权限验证相关的问题。下面我们就为大家具体介绍有关PHP全站权限验证的实现方法。#t#
成都创新互联从2013年开始,先为平江等服务建站,平江等地企业,进行企业商务咨询服务。为平江企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。
PHP全站权限验证代码示例:
用户:
密码:
----------------conn.php--------------------------
----------------------------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']
."登录系统";- }
- ?>
---------------------list.php-----------------
- < ?
- include 'check.php';
- ?>
- < html>
- < head>
- < script type="text/javascript"
src="player/swfobject.js">< /script>- < /head>
- < body>
- < h3>单个文件播放:< /h3>
- < 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>
- < h3>playlist file, with different
colors:< /h3>- < 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 "注销成功";
- ?>
以上就是PHP全站权限验证的具体实现方法。
网站标题:教你快速实现PHP全站权限验证
网站网址:http://www.shufengxianlan.com/qtweb/news18/503718.html
网站建设、网络推广公司-创新互联,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联