Home > Backend Development > PHP Tutorial > PHP user authentication and management complete source code_PHP tutorial

PHP user authentication and management complete source code_PHP tutorial

WBOY
Release: 2016-07-13 17:31:41
Original
1073 people have browsed it

-- begin auth.inc --  


(做为现在的主流开发语言)


$id = "xxxCOM";


if(!isset($php(做为现在的主流开发语言)_AUTH_USER)) {

Header("WWW-Authenticate: Basic realm="$id"");

Header("HTTP/1.0 401 Unauthorized");

require(error.inc);

exit;

}


$name = $php(做为现在的主流开发语言)_AUTH_USER;

$pass = $php(做为现在的主流开发语言)_AUTH_PW;

require("connect.inc");

$query = "select * from auth where username=$name && realm=$id";

$result = MySQL(和PHP搭配之最佳组合)_db_query("admin", $query);

if(MySQL(和PHP搭配之最佳组合)_num_rows($result) == 0) {


Header("WWW-Authenticate: Basic realm="$id"");

Header("HTTP/1.0 401 Unauthorized");

require(error.inc);

exit;

}


$active = MySQL(和PHP搭配之最佳组合)_result($result,0,"active");

if($active == no) {


?>  

  

404 Not Found  

  

Not Found

  

The requested URL  

  

was not found on this server.

  

  

(做为现在的主流开发语言)

exit;

}

?>  


-- end auth.inc --  


-- begin connect.inc --  


(做为现在的主流开发语言) MySQL(和PHP搭配之最佳组合)_connect("localhost", "user", ""); ?>  


-- end connect.inc --  


-- begin error.inc --  


此文件存放错误信息及返回!  


-- end error.inc --  


-- 用户库结构(自己调整)--  


CREATE TABLE auth (  

id smallint(6) DEFAULT 0 NOT NULL auto_increment,  

username varchar(16) DEFAULT NOT NULL,  

lastname tinyblob,  

firstname tinyblob,  

password varchar(16),  

realm varchar(16),  

active char(3),  

Prima(最完善的虚拟主机管理系统)RY KEY (id),  

UNIQUE id (id),  

UNIQUE username (username)  

);  


-- 用户库结构结束--  


-- 添加用户示例--  


insert into auth (username, lastname, firstname, password, realm, active) values (admin,my,love,password,xxxCOM,yes);  


-- 结束--  


--用户管理程序开始 usermanage.php(做为现在的主流开发语言) --  

(做为现在的主流开发语言) include("auth.inc"); ?>  

(做为现在的主流开发语言)


if ($php(做为现在的主流开发语言)_AUTH_USER != "admin") {

Header("WWW-Authenticate: Basic realm="xxxCOM 客户认证"");

Header("HTTP/1.0 401 Unauthorized");

echo "access(小型网站之最爱) Denied!n";

exit;

};


if ($php(做为现在的主流开发语言)_AUTH_PW != "mypassword") {

Header("WWW-Authenticate: Basic realm="xxxCOM 客户认证"");

Header("HTTP/1.0 401 Unauthorized");

echo "access(小型网站之最爱) Denied!n";

exit;

};


if ($activate) {


include("connect.inc");

$query1 = "UPDATE auth SET active=yes where id=$id";

$result1 = MySQL(The best combination with PHP)_db_query("admin", $query1);


if ($result1) {

echo "n";

echo "$user activatedn";

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/509057.htmlTechArticle-- begin auth.inc -- ?php (as the current mainstream development language) id = "xxxCOM" ; if(!isset(php (as the current mainstream development language) _AUTH_USER)) Header("WWW-Authenticate: Basic realm="id...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template