加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
department_add.php 3.99 KB
一键复制 编辑 原始数据 按行查看 历史
xiebin324 提交于 2020-04-18 13:50 . 提交
<?php
include_once('./config/init.php');
if($_POST)
{
// var_dump($_POST);
// exit;
// echo '通过了';
// exit;
//trim去除空格
$name = trim($_POST['name']);
$sql = "SELECT * FROM {$pre_}department WHERE name = '$name'";
$department = getOne($sql);
// var_dump($department);
// exit;
//如果数组不为空说明这个人已经存在了
if(!empty($department))
{
showMsg("该部门已经存在");
exit;
}
// echo '不存在';
// exit;
//不存在就意味着我们可以添加数据了
// var_dump($_POST);
// exit;
$data = [
'name'=>trim($_POST['name']),
];
// var_dump($data);
// exit;
//返回插入成功或失败的结果
$result = insert("department",$data);
// var_dump($result);
// exit;
if($result)
{
showMsg('添加部门成功','department_list.php');
exit;
}else{
showMsg('添加部门失败');
exit;
}
}
//查询部门
// $sql = "SELECT * FROM {$pre_}department";
// $deplist = getAll($sql);
//查询职位
// $sql = "SELECT * FROM {$pre_}job";
// $joblist = getAll($sql);
// var_dump($deplist,$joblist);
// exit;
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php include_once('meta.php'); ?>
</head>
<body>
<!-- 头部 -->
<?php include_once('header.php'); ?>
<!-- 菜单 -->
<?php include_once('menu.php'); ?>
<div class="content">
<div class="header">
<h1 class="page-title">添加部门</h1>
</div>
<ul class="breadcrumb">
<li><a href="index.php">首页</a> <span class="divider">/</span></li>
<li class="active">Index</li>
</ul>
<div class="container-fluid">
<div class="row-fluid">
<div class="btn-toolbar">
<button class="btn btn-primary" onClick="location='department_list.php'"><i class="icon-list"></i> 返回部门列表</button>
<div class="btn-group">
</div>
</div>
<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="name" required placeholder="请输入部门名称" class="input-xxlarge">
<!-- <label>文章内容</label>
<textarea value="Smith" rows="3" class="input-xxlarge"></textarea> -->
<label></label>
<input class="btn btn-primary" type="submit" value="提交" />
</form>
</div>
</div>
</div>
<div class="modal small hide fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Delete Confirmation</h3>
</div>
<div class="modal-body">
<p class="error-text"><i class="icon-warning-sign modal-icon"></i>Are you sure you want to delete the user?</p>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
<button class="btn btn-danger" data-dismiss="modal">Delete</button>
</div>
</div>
<footer>
<hr>
<p>&copy; 2017 <a href="#" target="_blank">copyright</a></p>
</footer>
</div>
</div>
</div>
</body>
</html>
<!-- 底部 -->
<?php include_once('footer.php'); ?>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化