代码拉取完成,页面将自动刷新
<?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>© 2017 <a href="#" target="_blank">copyright</a></p>
</footer>
</div>
</div>
</div>
</body>
</html>
<!-- 底部 -->
<?php include_once('footer.php'); ?>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。