1 Star 0 Fork 0

sky/company

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
adminAdd.php 3.70 KB
一键复制 编辑 原始数据 按行查看 历史
sky 提交于 2024-01-04 15:13 . 提交项目
<?php
include_once('config/config.php');
$LoginAdmin = checkAuth();
if($LoginAdmin['id'] != 1){
showMsg('暂无权限','admin.php');
}
if($_POST)
{
if(empty(trim($_POST['username']))){
showMsg('管理员昵称不能为空!');
}
if(empty(trim($_POST['password']))){
showMsg('密码不能为空!');
}
if(empty(trim($_POST['repass']))){
showMsg('确认密码不能为空!');
}
if(trim($_POST['password'] != trim($_POST['repass']))){
showMsg('密码与确认密码不一致!');
}
// 生成密码盐
$salt = build_ranstr();
$password = md5($_POST['password'] . $salt);
//封装数据
$data = array(
"username" => trim($_POST['username']),
"password" => $password,
"salt" => $salt
);
// 处理头像数据
$avatar = build_upload('avatar');
if($avatar['code'] === 0){
showMsg($avatar['msg']);
}
$data['avatar'] = $avatar['data'];
// 插入数据
$result = add('admin',$data);
if($result['code'] === 0){
showMsg($result['msg']);
}else{
showMsg($result['msg'],'admin.php');
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php include_once('common/meta.php'); ?>
</head>
<style>
input[type="file"]{
display: none;
}
label[for="avatar"]
{
width: 200px;
}
</style>
<body>
<?php include_once('common/header.php');?>
<?php include_once('common/menu.php') ?>>
<div class="content">
<div class="header">
<h1 class="page-title">添加管理员</h1>
</div>
<ul class="breadcrumb">
<li><a href="admin.php">admin</a> <span class="divider">/</span></li>
<li class="active">adminAdd</li>
</ul>
<div class="container-fluid">
<div class="row-fluid">
<div class="well">
<div id="myTabContent" class="tab-content">
<div class="tab-pane active in" id="home">
<form method="post" enctype="multipart/form-data">
<label>昵称</label>
<input type="text" name="username" placeholder="请输入管理员昵称" class="input-xxlarge">
<label>密码</label>
<input type="password" name="password" placeholder="请输入密码" class="input-xxlarge">
<label>确认密码</label>
<input type="password" name="repass" placeholder="请输入确认密码" class="input-xxlarge">
<label>头像</label>
<label for="avatar">
<img src="/assets/images/upload.png" id="upload" alt="">
</label>
<input type="file" name="avatar" id="avatar" class="input-xlarge">
<label></label>
<input class="btn btn-primary" type="submit" value="提交" />
</form>
</div>
</div>
</div>
<?php include_once('common/footer.php'); ?>
</div>
</div>
</div>
</body>
</html>
<?php include_once('common/script.php'); ?>
<script>
// 图片预览
$('#avatar').change(function(){
let file = $(this)[0].files[0];
if(file)
{
let reader = new FileReader();
reader.readAsDataURL(file)
// 事件
reader.onload = function()
{
$('#upload').attr('src',reader.result);
}
}
});
</script>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/JIE_XIAOQIU/company.git
git@gitee.com:JIE_XIAOQIU/company.git
JIE_XIAOQIU
company
company
master

搜索帮助