php 访问控制
<?php
// An array of allowed users and their passwords
$users = array(
'harryf' => 'secret',
'tom' => 'mypwd'
);
// If there's no Authentication header, exit
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('HTTP/1.1 401 Unauthorized');
header('WWW-Authenticate: Basic realm="PHP Secured"');
exit('This page requires authentication');
}
// If the user name doesn't exist, exit
if (!isset($users[$_SERVER['PHP_AUTH_USER']])) {
header('HTTP/1.1 401 Unauthorized');
header('WWW-Authenticate: Basic realm="PHP Secured"');
exit('Unauthorized!');
}
// Is the password doesn't match the username, exit
if ($users[$_SERVER['PHP_AUTH_USER']] != $_SERVER['PHP_AUTH_PW'])
{
header('HTTP/1.1 401 Unauthorized');
header('WWW-Authenticate: Basic realm="PHP Secured"');
exit('Unauthorized!');
}
echo 'You\'re in!';
?>
相关文档:
问题描述:一个连接远程数据库的PHP脚本testdb.php,在浏览器中运行:http://localhost/testdb.php,出现错误:Can't connect to MySQL server on '10.60.56.220' (13),但是在本地用php命令行运行:php testdb.php,却正常地连上了数据库并读出了其中的数据。
应用程序环境:本地IP:10.60.56.90,本地电脑上安装Apache 2 ......
<?php
class DB
{
private $link;
function connectDB($dbhost, $dbuser, $dbpw, $dbname="", $pconnect = 1)
{
if($pconnect)
{
if(!$this->link = mysql_pconnect($dbhost, $dbuser, ......
作者:http://blog.csdn.net/zhoufoxcn/archive/2009/11/05/4769858.aspx
说明:因为最近工作工作关系,需要开发一个在Linux下运行的Web
Application,需要对现在比较流行的一些PHP框架做一个了解和评估,下面的这篇文章是笔者最近学习一个比较新的PHP
Framework的一点经历和操作步骤,因为官方的手册写得比较晦 ......
HTML代码
<form action="" method="post">
<input name="ID_Dele[]" type="checkbox" id="ID_Dele[]" value="1"/>
<input name="ID_Dele[]" type="checkbox" id="ID_Dele[]" value="2"/>
<input name="ID_Dele[]" type="checkbox" id="ID_Dele[]" value="3"/>
<input name="ID_D ......