PHP实现用户认证及管理完全源码

时间:2021-05-26

--beginauth.inc--
<?php
$id="xxxCOM";
if(!isset($PHP_AUTH_USER)){
Header("客户认证"");
Header("HTTP/1.0401Unauthorized");
echo"AccessDenied!n";
exit;
};
if($activate){
include("connect.inc");
$query1="UPDATEauthSETactive='yes'whereid='$id'";
$result1=mysql_db_query("admin",$query1);
if($result1){
echo"<fontsize="+1">n";
echo"$useractivatedn";
echo"<br>n<ahref="$PHP_SELF">返回</a>\n";
echo"</font>n";
exit;
}else{
echo"<fontsize="+1">n";
echo"Error:UnknownErrorn";
echo"<br>n<ahref="$PHP_SELF">返回</a>\n";
echo"</font>n";
exit;
}
}
if($deactivate){
include("connect.inc");
$query2="UPDATEauthSETactive='no'whereid='$id'";
$result2=mysql_db_query("admin",$query2);
if($result2){
echo"<fontsize="+1">n";
echo"$userdeactivatedn";
echo"<br>n<ahref="$PHP_SELF">返回</a>\n";
echo"</font>n";
exit;
}else{
echo"<fontsize="+1">n";
echo"Error:UnknownErrorn";
echo"<br>n<ahref="$PHP_SELF">返回</a>\n";
echo"</font>n";
exit;
}
}
if($delete){
include("connect.inc");
$query3="deletefromauthwhereid='$id'";
$result3=mysql_db_query("admin",$query3);
if($result3){
echo"<fontsize="+1">n";
echo"$user已删除!n";
echo"<br>n<ahref="$PHP_SELF">返回</a>\n";
echo"</font>n";
exit;
}else{
echo"<fontsize="+1">n";
echo"Error:UnknownErrorn";
echo"<br>n<ahref="$PHP_SELF">返回</a>\n";
echo"</font>n";
exit;
}
}
echo"<html>n";
echo"<head>n";
echo"<title>用户管理</title>n";
echo"</head>n";
echo"<body>n";
echo"<formmethod="post"action="$PHP_SELF">\n";
echo"<tableborder="1">n";
echo"<tr><th><fontsize="+1">Username</font></th><th><fontsize="+1">RealName</font></th><th><fontsize="+1">Activated</font></th></tr>n";
include("connect.inc");
$query="SELECT*FROMauth";
$result=mysql_db_query("admin",$query);
if($result){
while($r=mysql_fetch_array($result)){
$id=$r["id"];
$username=$r["username"];
$lastname=$r["lastname"];
$firstname=$r["firstname"];
$activated=$r["active"];
if($activated=="yes"){
echo"<tr><td><fontsize="+1">$username</font></td><td><fontsize="+1">$lastname,$firstname</font></td><td><fontsize="+1">$activated</font></td><td><ahref="$PHP_SELF?deactivate=yes&id=$id&user=$username">Deactivate</a></td><td><ahref="$PHP_SELF?delete=yes&id=$id">Delete</a></td></tr>n";
}elseif($activated=="no"){
echo"<tr><td><fontsize="+1">$username</font></td><td><fontsize="+1">$lastname,$firstname</font></td><td><fontsize="+1">$activated</font></td><td><ahref="$PHP_SELF?activate=yes&id=$id">Activate</a></td><td><ahref="$PHP_SELF?delete=yes&id=$id">Delete</a></td></tr>n";
}
}
}
mysql_free_result($result);
echo"</table>\n";
echo"</body>\n";
echo"</html>\n";
?>
--usermanage.php结束--

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章