<!DOCTYPE html>
<html>
<head>
	<title>人员管理系统</title>
	<meta charset='utf-8'>
	<link rel='stylesheet' href='style.css'>
</head>
<body>
	<div id='login'>
		<h2>管理员登录</h2>
		<form action='login.php' method='post'>
			<label for='username'>用户名:</label>
			<input type='text' name='username' required>
			<label for='password'>密码:</label>
			<input type='password' name='password' required>
			<input type='submit' value='登录'>
		</form>
	</div>
	<div id='main' style='display: none;'>
		<h2>人员信息管理</h2>
		<div id='toolbar'>
			<button id='add'>添加人员</button>
			<button id='edit'>修改人员</button>
			<button id='delete'>删除人员</button>
			<input type='text' id='search' placeholder='按姓名、性别、年龄、手机号码查询'>
			<button id='query'>查询</button>
			<label for='sort'>排序:</label>
			<select id='sort'>
				<option value='name'>姓名</option>
				<option value='gender'>性别</option>
				<option value='age'>年龄</option>
				<option value='phone'>手机号码</option>
			</select>
			<button id='sortBtn'>排序</button>
			<button id='chartBtn'>生成图表</button>
			<button id='export'>导出数据</button>
		</div>
		<table id='personTable'>
			<thead>
				<tr>
					<th>姓名</th>
					<th>性别</th>
					<th>年龄</th>
					<th>手机号码</th>
					<th>请假</th>
					<th>加班</th>
					<th>出差</th>
				</tr>
			</thead>
			<tbody>
			</tbody>
		</table>
	</div>
	<div id='dialog' style='display: none;'>
		<h2 id='dialogTitle'></h2>
		<form id='personForm'>
			<label for='name'>姓名:</label>
			<input type='text' id='name' name='name' required>
			<label for='gender'>性别:</label>
			<input type='radio' name='gender' value='male' checked>男
			<input type='radio' name='gender' value='female'>女
			<label for='age'>年龄:</label>
			<input type='number' id='age' name='age' required>
			<label for='phone'>手机号码:</label>
			<input type='tel' id='phone' name='phone' required>
			<label for='leave'>请假:</label>
			<input type='checkbox' id='leave' name='leave'>
			<label for='overtime'>加班:</label>
			<input type='checkbox' id='overtime' name='overtime'>
			<label for='travel'>出差:</label>
			<input type='checkbox' id='travel' name='travel'>
			<input type='submit' value='保存'>
			<button id='cancel'>取消</button>
		</form>
	</div>
	<div id='chart' style='display: none;'>
		<h2 id='chartTitle'></h2>
		<canvas id='chartCanvas'></canvas>
		<button id='chartClose'>关闭</button>
	</div>
	<script src='jquery.min.js'></script>
	<script src='chart.min.js'></script>
	<script src='main.js'></script>
</body>
</html>
<p>后台代码:</p>
<?php
	session_start();
	if (!isset($_SESSION['username'])) {
		header('Location: index.php');
		exit();
	}
?>
<!DOCTYPE html>
<html>
<head>
	<title>人员管理系统 - 后台</title>
	<meta charset='utf-8'>
	<link rel='stylesheet' href='style.css'>
</head>
<body>
	<h2>欢迎 <?php echo $_SESSION['username']; ?> 登录人员管理系统</h2>
	<p><a href='logout.php'>退出登录</a></p>
</body>
</html>
<p>PHP代码:</p>
<?php
	session_start();
	if ($_SERVER['REQUEST_METHOD'] == 'POST') {
		$username = $_POST['username'];
		$password = $_POST['password'];
		if ($username == 'admin' && $password == 'admin123') {
			$_SESSION['username'] = 'admin';
			header('Location: main.php');
			exit();
		} else {
			$message = '用户名或密码错误';
		}
	}
?>
<!DOCTYPE html>
<html>
<head>
	<title>人员管理系统 - 登录</title>
	<meta charset='utf-8'>
	<link rel='stylesheet' href='style.css'>
</head>
<body>
	<h2>人员管理系统 - 登录</h2>
	<?php if (isset($message)) { ?>
		<p class='error'><?php echo $message; ?></p>
	<?php } ?>
	<form action='' method='post'>
		<label for='username'>用户名:</label>
		<input type='text' name='username' required>
		<label for='password'>密码:</label>
		<input type='password' name='password' required>
		<input type='submit' value='登录'>
	</form>
</body>
</html>
在线小型人员管理系统 - 前后端代码示例

原文地址: https://www.cveoy.top/t/topic/nqVR 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录