效果图
前期准备
数据库准备
1、在mysql中创建数据库member
CREATE DATABASE MEMBER;
2、根据id、username、psd、email、sex、createtime、ad七个字段建立数据表userinfo
CREATE TABLE userinfo(
id INT(8) PRIMARY KEY,
username VARCHAR(32) NOT NULL,
psd VARCHAR(32) NOT NULL,
email VARCHAR(32) NOT NULL,
sex TINYINT(1) NOT NULL,
createtime DATE NOT NULL,
ad TINYINT(1) NOT NULL
)
3、插入几条用户信息
insert into userinfo values(1,'张三','1223456','1233@163.com','1','2002-11-01','0');
insert into userinfo values(2,'李四','1234256','1223@163.com','0','2004-02-01','0');
insert into userinfo values(3,'王五','12123456','1243@163.com','1','2001-03-11','0');
insert into userinfo values(4,'赵六','1252246','1237@163.com','1','2005-04-21','0');
insert into userinfo values(5,'钱七','1236356','1283@163.com','1','2001-05-11','0');
框架引入
bootstrap
平台界面设计布局与组件用到bootstrap框架,采取直接引入的方式
bootstrap地址:警告框(Alert) · Bootstrap v4 中文文档 v4.6 | Bootstrap 中文网 (bootcss.com)
引入方式:下载bootstrap生产文件,并通过直接引入使用。
<script src="jquery.3.7.1/jquery-3.7.1.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css">
<script src="https://cdn.bootcss.com/popper.js/1.14.7/umd/popper.min.js"></script>
<link rel="stylesheet" href="bootstrap-4.6.2-dist/css/bootstrap.min.css">
<script src="bootstrap-4.6.2-dist/js/bootstrap.min.js"></script>
layui
layui地址: 开始使用 - Layui 文档
用户管理系统中编辑用户信息需要使用到信息弹窗,这里采用layui的Layer弹出层来实现。
通过进入官网直接下载layui文件,随后直接引入即可使用
<script src="layui/layui.js"></script>
用户管理平台
user.php
user.php文件作为用户管理平台,包括侧边栏页面切换和,主部用户信息展示。用户信息展示包括搜索框实现php访问数据库查询,编辑按钮编辑数据库用户数据,删除按钮进行用户信息删除,以及管理员设置,后台添加或删除管理员权限。
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>用户后台管理</title>
<script src="jquery.3.7.1/jquery-3.7.1.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css">
<script src="https://cdn.bootcss.com/popper.js/1.14.7/umd/popper.min.js"></script>
<link rel="stylesheet" href="bootstrap-4.6.2-dist/css/bootstrap.min.css">
<script src="bootstrap-4.6.2-dist/js/bootstrap.min.js"></script>
<script src="layui/layui.js"></script>
<style>
html,body{
height: 100%;
}
.header{
width: 100%;
height: 100px;
background: rgba(36,77,106,0.7);
display: flex;
}
.dropdown{
margin-top: 15px;
margin-left: 120px;
margin-left: 680px;
}
.main{
width: 100%;
height: 100%;
background: url("图片素材/back.jpg");
}
.home{
width: 100%;
height: 100%;
padding: 1px;
}
.all{
display: flex;
width: 100%;
height: 100%;
}
.niceButton{
display: inline-block;
padding: 5px 15px;
font-size: 16px;
cursor: pointer;
text-align: center;
text-decoration: none;
outline: none;
color:#fff;
background-color: rgb(16, 185, 214);
border: none;
border-radius: 15px;
box-shadow: 0 9px #999;
}
.niceButton:hover{
background-color: #1795bb;
}
.niceButton:active{
background-color: #1795bb;
box-shadow: 0 5px #666;
transform:translateY(4px);
}
.search{
margin-top: 20px;
display: flex;
margin-bottom: 20px;
margin-left: 900px;
}
.form-control{
width: 380px;
}
.input-group{
width: 430px;
}
.btn-logo{
background: rgba(241,207,246,0);
width: 70px;
height: 60px;
border: 0;
}
.side{
width: 15%;
height: 100%;
background: rgba(71,154,211,0.7);
}
.side h3{
color: white;
text-align: center;
margin-top: 20px;
}
.row{
width: 500px;
margin-left: 30px;
margin-top: 20px;
}
.list-group{
background: rgba(248,248,248,0.16);
}
</style>
</head>
<body>
<div class="all">
<div class="side">
<b><h3>用户后台管理</h3></b>
<div class="row">
<div class="col-4">
<div class="list-group" id="list-tab" role="tablist">
<a style="background: rgba(213,230,239,0.73);color: black" href="datashow.php" class="list-group-item list-group-item-action " role="tab" aria-controls="home">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-house-fill" viewBox="0 0 16 16">
<path d="M8.707 1.5a1 1 0 0 0-1.414 0L.646 8.146a.5.5 0 0 0 .708.708L8 2.207l6.646 6.647a.5.5 0 0 0 .708-.708L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293L8.707 1.5Z"/>
<path d="m8 3.293 6 6V13.5a1.5 1.5 0 0 1-1.5 1.5h-9A1.5 1.5 0 0 1 2 13.5V9.293l6-6Z"/>
</svg>
首页</a>
<a href="manager.php" class="list-group-item list-group-item-action active" id="list-profile-list" role="tab" aria-controls="profile">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-person-fill" viewBox="0 0 16 16">
<path d="M3 14s-1 0-1-1 1-4 6-4 6 3 6 4-1 1-1 1H3zm5-6a3 3 0 1 0 0-6 3 3 0 0 0 0 6z"/>
</svg>
用户管理</a>
<a style="background: rgba(213,230,239,0.73);color: black" href="waters.php" class="list-group-item list-group-item-action" id="list-messages-list" role="tab" aria-controls="messages">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-water" viewBox="0 0 16 16">
<path d="M.036 3.314a.5.5 0 0 1 .65-.278l1.757.703a1.5 1.5 0 0 0 1.114 0l1.014-.406a2.5 2.5 0 0 1 1.857 0l1.015.406a1.5 1.5 0 0 0 1.114 0l1.014-.406a2.5 2.5 0 0 1 1.857 0l1.015.406a1.5 1.5 0 0 0 1.114 0l1.757-.703a.5.5 0 1 1 .372.928l-1.758.703a2.5 2.5 0 0 1-1.857 0l-1.014-.406a1.5 1.5 0 0 0-1.114 0l-1.015.406a2.5 2.5 0 0 1-1.857 0l-1.014-.406a1.5 1.5 0 0 0-1.114 0l-1.015.406a2.5 2.5 0 0 1-1.857 0L.314 3.964a.5.5 0 0 1-.278-.65zm0 3a.5.5 0 0 1 .65-.278l1.757.703a1.5 1.5 0 0 0 1.114 0l1.014-.406a2.5 2.5 0 0 1 1.857 0l1.015.406a1.5 1.5 0 0 0 1.114 0l1.014-.406a2.5 2.5 0 0 1 1.857 0l1.015.406a1.5 1.5 0 0 0 1.114 0l1.757-.703a.5.5 0 1 1 .372.928l-1.758.703a2.5 2.5 0 0 1-1.857 0l-1.014-.406a1.5 1.5 0 0 0-1.114 0l-1.015.406a2.5 2.5 0 0 1-1.857 0l-1.014-.406a1.5 1.5 0 0 0-1.114 0l-1.015.406a2.5 2.5 0 0 1-1.857 0L.314 6.964a.5.5 0 0 1-.278-.65zm0 3a.5.5 0 0 1 .65-.278l1.757.703a1.5 1.5 0 0 0 1.114 0l1.014-.406a2.5 2.5 0 0 1 1.857 0l1.015.406a1.5 1.5 0 0 0 1.114 0l1.014-.406a2.5 2.5 0 0 1 1.857 0l1.015.406a1.5 1.5 0 0 0 1.114 0l1.757-.703a.5.5 0 1 1 .372.928l-1.758.703a2.5 2.5 0 0 1-1.857 0l-1.014-.406a1.5 1.5 0 0 0-1.114 0l-1.015.406a2.5 2.5 0 0 1-1.857 0l-1.014-.406a1.5 1.5 0 0 0-1.114 0l-1.015.406a2.5 2.5 0 0 1-1.857 0L.314 9.964a.5.5 0 0 1-.278-.65zm0 3a.5.5 0 0 1 .65-.278l1.757.703a1.5 1.5 0 0 0 1.114 0l1.014-.406a2.5 2.5 0 0 1 1.857 0l1.015.406a1.5 1.5 0 0 0 1.114 0l1.014-.406a2.5 2.5 0 0 1 1.857 0l1.015.406a1.5 1.5 0 0 0 1.114 0l1.757-.703a.5.5 0 1 1 .372.928l-1.758.703a2.5 2.5 0 0 1-1.857 0l-1.014-.406a1.5 1.5 0 0 0-1.114 0l-1.015.406a2.5 2.5 0 0 1-1.857 0l-1.014-.406a1.5 1.5 0 0 0-1.114 0l-1.015.406a2.5 2.5 0 0 1-1.857 0l-1.757-.703a.5.5 0 0 1-.278-.65z"/>
</svg>
水域管理</a>
</div>
</div>
</div>
</div>
<div class="main">
<div class="header">
<div style="margin-top: 30px;margin-left: 20px;color: white">
<b><h3>管理员与用户统一管理平台</h3></b>
</div>
<div class="dropdown">
<button class="btn-logo" type="button" data-toggle="dropdown" aria-expanded="false">
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="login.php">退出登录</a>
<!--
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
-->
</div>
</div>
</div>
<div class="home">
<div class="search">
<div class="input-group flex-nowrap">
<div class="input-group-prepend">
<span class="input-group-text " id="addon-wrapping"><i class="bi bi-search"></i></span>
</div>
<form action="manager.php" method="post" style="width: 300px" >
<input type="text" class="form-control" placeholder="姓名" aria-label="Username" aria-describedby="addon-wrapping" name="search">
</div>
<input type="submit" class="btn btn-primary" name="btn" >
</form>
</div>
<?
$conn=mysqli_connect("localhost","root","")or die("连接服务器失败");
mysqli_select_db($conn,"member")or die("选择数据库错误");
mysqli_query($conn,"set names utf8");
include_once 'page.php';
$sql="select count(id) as total from userinfo";
$result = mysqli_query($conn,$sql);
$info = mysqli_fetch_array($result);
$total = $info['total'];
$perPage=10;
$page=empty( $_GET['page'])? 1 :$_GET['page'];
paging($total,$perPage);
if(!empty($_POST['btn'])){
$search=$_POST['search'];
}
$sql=empty($search)? "select * from userinfo order by id desc limit $firstCount,$displayPG" : "select * from userinfo where username like '$search%' order by id desc limit $firstCount,$displayPG" ;
$result=mysqli_query($conn,$sql);
?>
<table class="table table-hover table-dark" style="width: 95%;margin-left: 35px;background: rgba(255,255,255,0.70);color: black;">
<thead>
<tr>
<th scope="col">编号</th>
<th scope="col">用户名</th>
<th scope="col">邮箱</th>
<th scope="col">性别</th>
<th scope="col">密码</th>
<th scope="col">创建时间</th>
<th scope="col">是否为管理员</th>
<th scope="col">操作</th>
</tr>
</thead>
<?
$i=($page-1)*$perPage+1;
while($info =mysqli_fetch_array($result)){
?>
<tbody>
<tr>
<th scope="row"><? echo $i; ?></th>
<td><? echo $info['username']; ?></td>
<td><? echo $info['email']; ?></td>
<td><? echo $info['sex']?'男' :'女'; ?></td>
<td><? echo $info['password']; ?></td>
<td><? echo $info['createtime']; ?></td>
<td><? echo $info['ad']?'是':'否'; ?></td>
<td>
<? if($info['username']!='admin'){ ?> <button class="niceButton"><b><a style="color:rgba(255,45,57,0.8)" href="javascript:del(<?php echo $info['id'];?>,'<? echo $info['username'];?>');">删除</a></b></button>
<?php
}
if($info['username']!='admin'){ ?> <button class="niceButton"><b><a style="color:rgba(255,255,255,1)" href="javascript:open('update.php',<?php echo $info['id'];?>);">编辑</a></b></button>
<?php
}
if($info['admin']){
if($info['username']!='admin'){
?><button class="niceButton"><b><a href="setAdmin.php?action=0&id=<?php echo $info['id'];?>">取消管理员</a></b></button>
<?php
}else{
echo '<span style="color:gray">取消管理员</span>';
}
}else{
if($info['username']!='admin'){
?><button class="niceButton"><b><a href="setAdmin.php?action=1&id=<?php echo $info['id'];?>">设置管理员</a></b></button>
<?php
}
else{
echo '<span style="color:gray">设置管理员</span>';
}
}
?>
</td>
</tr>
</tbody>
<?
$i++;
}
?>
</table>
<div style="margin-left: 450px;color: white">
//引入分页文件
<?
echo $pageNav;
?>
</div>
</div>
</div>
</div>
<script>
function del(id,name){
if(confirm('您确定要删除会员 '+name+' 吗?')){
location.href = 'del.php?id=' + id+'&username=' + name;
}
}
function open(url,id){
layer.open({
type: 2,
title:'',
shadeClose: true,
maxmin: true, //开启最大化最小化按钮
area: ['1000px','600px'],
content:'update.php?id=' + id ,
}
);
}
function closeLayer(){
layer.closeAll();
}
function refresh(){
location.reload();
}
</script>
</body>
</html>
page.php
分页文件实现分页功能,在user.php中调用即可。
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>
<body>
</body>
</html>
<?
if(!function_exists('paging')){
function paging($total,$displayPG=20,$url=''){
global $page,$firstCount,$pageNav,$_SERVER;
$GLOBALS["displayPG"]=$displayPG;
$page= empty( $_GET['page']) ? 1:$_GET['page'];
if(!$url){
$url=$_SERVER["REQUEST_URI"];
}
$parse_url=parse_url($url);
$url_query=empty( $parse_url["query"]) ? '':$parse_url["query"];
if($url_query){
$url_query=preg_replace("/(^|&)page=$page/","",$url_query);
$url=str_replace($parse_url["query"],$url_query,$url);
if($url_query) $url.="$page";else $url.="page";
}
else{
$url.="?page";
}
$lastpg=ceil($total/$displayPG);
$page=min($lastpg,$page);
$prepg=$page-1;
$nextpg=($page==$lastpg ? 0 : $page+1);
$firstCount=($page-1)*$displayPG;
$pageNav="第<B>"." ".($total?($firstCount+1):0)." "."</B>-<B>".min($firstCount+$displayPG,$total)." "."</B>条,共<B>$total</B>条记录";
if($lastpg<=1) return false;
$pageNav.=" <a href=$url=1 mce_href=$url=1>首页</a>";
if($prepg) $pageNav.=" <a href=$url=$prepg mce_href=$url=$prepg>上一页</a>";else $pageNav.=" 上一页";
if($nextpg) $pageNav.=" <a href=$url=$nextpg mce_href=$url=$nextpg>下一页</a>";else $pageNav.=" 下一页";
$pageNav.=" <a href=$url=$lastpg mce_href=$url=$lastpg>尾页</a>";
$pageNav.=" 到第<select name='topage' size='1' style='font-size:12px' mce_style='font-size:12px' onchange='window.location=\"$url=\"+this.value'>\n";
for($i=1;$i<=$lastpg;$i++){
if($i==$page) $pageNav.="<option value='$i' selected>$i</option>\n";
else $pageNav.="<option value='$i'>$i</option>\n";
}
$pageNav .=" </select>页,共 $lastpg 页";
}
}
?>
del.php
删除文件通过在php中连接数据库member的userinfo表,根据主页面传来的id数据进行识别定位,并且调用sql删除语句,“delete from userinfo where id = $id”;进行数据库中用户信息的删除。在user.php中通过del方法调用即可。
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>
<body>
</body>
</html>
<?
$conn=mysqli_connect("localhost","root","")or die("连接服务器失败");
mysqli_select_db($conn,"member")or die("选择数据库错误");
mysqli_query($conn,"set names utf8");
$id=$_GET['id'];
$username=$_GET['username'];
if(is_numeric($id)){
$sql = "delete from userinfo where id=$id";
$result=mysqli_query($conn,$sql);
if($result){
echo "<script>alert('删除用户 $username 成功!');location.href='manager.php';</script>";
}
else{
echo "<script>alert('删除用户 $username 失败!');history.back();</script>";
}
}
else{
echo "<script>alert('参数错误!');history.back();</script>";
}
?>
setAdmin.php
设置管理员权限功能通过user.php传递而来的id参数找到相应用户,并且在user.php中已经实现判定当前用户的管理员权限,并传递相应数值action。并调用setAdmin方法,在setAdmin.php文件中根据传递的action值进行更改该用户权限。
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>
<body>
</body>
</html>
<?
$action=$_GET['action'];
$id=$_GET['id'];
if(is_numeric($action)&& is_numeric($id)){
if($action ==1 ||$action ==0){
//取消管理员
$sql ="update userinfo set ad=$action where id=$id";
}else{
echo "<script>alert('参数错误');history.back();</script>";
}
$conn=mysqli_connect("localhost","root","")or die("连接服务器失败");
mysqli_select_db($conn,"member")or die("选择数据库错误");
mysqli_query($conn,"set names utf8");
$result=mysqli_query($conn,$sql);
if($result){
echo "<script>alert('设置或取消管理员成功');location.href='manager.php';</script>";
}else{
echo "<script>alert('设置或取消管理员失败');history.back();</script>";
}
}else{
echo "<script>alert('参数错误');history.back();</script>";
}
?>
update.php
用户信息修改功能通过update.php文件配合updatePost.php文件实现,仍然通过首页传递的选中id参数,进入update.php进行数据库连接查询,并显示该用户的信息记录。此时update.php文件将通过layer弹窗进行展示。可是实现不跳转修改,在修改过后,利用表单的Post传递数据到updatePost.php文件。
<?
session_start();
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<style>
#previewApp {
box-sizing: border-box;
position:fixed;
top:0px;
left:0px;
bottom:0px;
right:0px;
width:330%;
height:480%;
border:none;
margin:0;
padding:0;
overflow:hidden;
z-index:99;
}
.form{
width: 300px;
height: 450px;
background-color:rgba(149,154,246,0.65) ;
box-shadow: rgba(3, 102, 214, 0.3) 0px 0px 0px 3px;
}
.form td{
font-size: 20px;
}
h1{
font-size: 24px;
}
h1 a{
color: navy;text-decoration: none;margin-right: 15px;
}
h1 a:last-child{
margin-right: 0;
}
h1 a:hover{
color: brown;text-decoration: underline
}
.current{
color:brown;
}
.logo{
width: 100%;
height: 125px;
background: rgba(10,255,150,0.60);
margin-top: 76px;
}
</style>
</head>
<body style="width: 300px;height: 450px;">
<div class="form" >
<?
$conn=mysqli_connect("localhost","root","")or die("连接服务器失败");
mysqli_select_db($conn,"member")or die("选择数据库错误");
mysqli_query($conn,"set names utf8");
$id=$_GET['id'];
$sql="select * from userinfo where id= $id";
$result = mysqli_query($conn,$sql);
if(mysqli_num_rows($result)){
$info = mysqli_fetch_array($result);
}
else{
die("未找到有效用户");
}
?>
<h1 style="text-align: center">
<a href="update.php" class="current">用户编辑</a>
</h1>
<form action="updatePost.php" method="post" style="m">
<table align="center" border="0" style="mar border-collapse: collapse" cellpadding="10" cellspacing="0">
<tr>
<td><b>编号</b></td>
<td><input name="id" type="number" value="<? echo $info['id'];?>"></td>
</tr>
<tr>
<td><b>用户名</b></td>
<td><input name="username" value="<? echo $info['username'];?>"></td>
</tr>
<tr>
<td><b>密码</b></td>
<td><input name="password" type="password" placeholder="不修改密码请留空"></td>
</tr>
<tr>
<td><b>确认密码</b></td>
<td><input name="cpassword" type="password" placeholder="不修改密码请留空"></td>
</tr>
<tr>
<td><b>性别</b></td>
<td>
<input name="sex" type="radio" <? if($info['sex']){?> checked <?}?>value="1">男
<input name="sex" type="radio"<? if(!$info['sex']){?> checked <?}?> value="0">女
</td>
</tr>
<tr>
<td><b>邮箱</b></td>
<td>
<input name="email" type="text" value="<? echo $info['email'];?>">
</td>
</tr>
<tr>
<td><b>创建时间</b></td>
<td>
<input name="createtime" type="date" value="<? echo $info['createtime'];?>">
</td>
</tr>
</table>
<div style="width: 100%;height: 50px;margin-top: 10px;" >
<button style="font-size: 20px;margin-left: 20px;margin-top: 5px;background: rgba(5,224,239,1.00);border: 0;box-shadow: rgba(0, 0, 0, 0.25) 0px 54px 55px, rgba(0, 0, 0, 0.12) 0px -12px 30px, rgba(0, 0, 0, 0.12) 0px 4px 6px, rgba(0, 0, 0, 0.17) 0px 12px 13px, rgba(0, 0, 0, 0.09) 0px -3px 5px;border-radius: 30px;width: 100px;height: 50px;" type="submit" value="确定">确定</button>
<button style="font-size: 20px;margin-left: 50px;background: rgba(5,224,239,1.00);border: 0;box-shadow: rgba(0, 0, 0, 0.25) 0px 54px 55px, rgba(0, 0, 0, 0.12) 0px -12px 30px, rgba(0, 0, 0, 0.12) 0px 4px 6px, rgba(0, 0, 0, 0.17) 0px 12px 13px, rgba(0, 0, 0, 0.09) 0px -3px 5px;border-radius: 30px;width: 100px;height: 50px;" type="reset" value="重置">重置</button>
</div>
</form>
</div>
</body>
</html>
updatePost.php
编辑功能文件updatePost.php利用$_POST[]来接收update.php已经进行修改的数据,并连接数据库调用sql语句"update userinfo set ***='$***'来进行数据修改。同时修改后刷新页面,调用close方法关闭弹窗,使得数据快速更新。实现后台用户数据编辑。
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>
<body>
</body>
</html>
<?
$id=$_POST['id'];
$username=trim($_POST['username']);
$password=trim($_POST['password']);
$cpassword=trim($_POST['cpassword']);
$sex=$_POST['sex'];
$email=$_POST['email'];
$createtime=$_POST['createtime'];
//连接数据库
$conn=mysqli_connect("localhost","root","")or die("连接服务器失败");
mysqli_select_db($conn,"member")or die("选择数据库错误");
mysqli_query($conn,"set names utf8");
//判断是否输入名字
if( ! strlen($username)){
echo "<script>alert('用户名必须填写!');history.back();</script>";
exit();
}
if(!empty($password)){
密码和确认密码的验证
if($password <> $cpassword){
echo "<script>alert('密码和确认密码必须相同!');history.back();</script>";
exit();
}
}
//判断用户名是否被占用
if(!empty($email)){
if(!preg_match('/^[a-zA-Z0-9_\-]+@([a-zA-Z0-9]+\.)+(com|cn|net|org)$/',$email)){
echo "<script>alert('邮箱格式不正确!');history.back();</script>";
exit();
}
}
if($password){
$sql="update userinfo set username='$username', password='$password',email='$email',sex='$sex',createtime='$createtime' where id='$id' ";
}else{
$sql="update userinfo set username='$username',email='$email',sex='$sex',createtime='$createtime' where id='$id'";
}
$result=mysqli_query($conn,$sql);
if($result){
echo "<script>alert('用户编辑成功!');window.parent.refresh();window.parent.closeLayer();</script>";
}
else{
echo "<script>alert('用户编辑失败!');history.back();</script>";
}
?>
总结
php连接mysql主要利用sql增删改查的语句调用,来进行用户与管理员的权限管理和信息删改。配合bootstrap和layui框架,搭建合理的用户管理平台,更好的实现系统集中管理已注册用户。