Mask appointment management system-system website implementation (front-end + PHP + MySQL)

Realization of the website of the mask appointment management system

I. Introduction

2. System login logic and interface realization

Three, user module

1. User appointment system interface

2. User view my order interface

3. The user modifies the appointment information

Fourth, the administrator module

1. Administrator login interface

 2. View user reservation orders

3. Modify/delete user information

Five, the courier module

1. The courier logs into the distribution system

2. Take orders

3. Close the order

Six, system implementation summary

1. Security

2. User appointment time

3. The front and back ends interact with the database


Realization of the website of the mask appointment management system

I. Introduction

In the previous article " Mask appointment management system-database design (front-end + PHP + MySQL) ", the database design of the mask appointment management system is basically completed. The goal of this project is to achieve a relatively complete and fully functional simulated mask appointment Management system, so this article will complete the next work-system website front-end (HTML+CSS+Javascript) and back-end (PHP), and realize the interaction between the front-end and the MySQL database . The implementation functions are briefly described as follows:

  • User module: Create an account , log in to the system to make an appointment to confirm the submission of the mask , view the status of the order , modify the order reservation information , and modify the personal registration information.
  • Municipal staff (administrator) module: query registered user information , modify or delete user information, review orders and assign couriers. Manage each type of mask, check the inventory quantity , reasonably allocate the number of masks reserved by the user, and check the delivery status of the order as required to facilitate data analysis.
  • Courier module: View the assigned orders , select the order delivery, complete the delivery, select the closed order , view the order according to the order status , and count the number of completed orders.

2. System login logic and interface realization

The system login page performs security management for the system. The accounts and passwords of the three roles are stored in the admin, users, and deliver tables. According to different login users, different permissions are designed to enter different modules. The login module flowchart:

The system interface uses a simple login page:

Input box, user type box and login button, the back end of the login page uses login_check.php to process user request information and return the result. The front-end, back-end, and database interact to retrieve the login identity. If there is an account record, the login is successful, otherwise the login fails.
The technologies used to implement the entire system include HTML5, CSS3, Javascript, PHP, and MySQL databases. Use and combine these technologies to make the system present a friendly operation page and system function guidance. The following will introduce each function page and key code.

Three, user module

1. User appointment system interface

The front-end elements used include input box, drop-down box, date selection box, text area and Button button, see the code implementation for details:

Front-end page code:

<!--user.php-->
<?php
//检查是否存在登录session,否则跳转登录界面
session_start();
require_once 'mysql_connect.php';
if ( !isset( $_SESSION[ 'user_id' ] ) ) {
	header( "Location:maskorder.php" );
	exit( '非法访问!' );
}
error_reporting( E_ERROR );
mysqli_query( $link, "set names 'utf8'" );
$id = $_SESSION[ 'user_id' ];
$query = "select * from users where user_id='$id' ";
$result = mysqli_query( $link, $query );
$arr = mysqli_fetch_array( $result );

?>
<!doctype html>
<html>
<head>
	<meta charset="utf-8">
	<title>口罩预约系统</title>
	<link rel="stylesheet" href="css/person.css" type="text/css">
	<style type="text/css">
		#res_form {
			/*表的宽度以及位置*/
			width: 500px;
			position: relative;
			left: 500px;
			top: 100px;
		}
		
		#a {
			/*调整input输入框与文字位置,显示同一行*/
			height: 50px;
			border: 1px;
			margin: 10px;
			text-align: left;
		}
		
		#a input {
			border: 1px solid #000000;
			/*按钮边缘*/
			border-radius: 5px;
			float: right;
		}
		
		#a select {
			border: 5px;
			width: 200px;
			border-color: #000000;
			border-radius: 5px;
			float: right;
		}
		
		#textarea {
			float: right;
			width: 200px;
		}
		
		#bt input {
			float: left;
			margin: 10px;
			width: 50px;
			background-color: #3CF;
			border-bottom-color: #000000;
			border-radius: 5px;
			position: relative;
			top: 20px;
			left: 100px;
		}
		
		#bt input:hover {
			background-color: #F00;
			color: #FFF;
			cursor: pointer;
		}
		
		#out {
			display: block;
			position: relative;
			left: 10px;
		}
		
		img {
			position: relative;
			float: right;
		}
		
		#we {
			position: relative;
			right: 100px;
		}
		
		h1 {
			position: absolute;
			float: left top;
			left: 660px;
		}
	</style>
</head>

<body>
	<div id="res">
		<ul id="item">
			<img src="images/2.png"></img>
			<div id="out">
				<div id="we">欢迎您&nbsp;&nbsp;
					<?php
					echo $id;
					?>&nbsp;,</div>
			<!--此处未改好样式-->
			<li><a href="login_out.php">退出登录</a>
			</li>
			<li><a href="adm_up_user.php" target="_blank">修改密码</a>
			</li>
			<li><a href="myorder.php">我的订单</a>
			</li>
		</ul>
	</div>
	<h1>口罩预约系统</h1>
	<div id="res_form">
		<form action="reserveorder.php" method="post">
			<div id="a">
				姓名
				<!--placeholder="预约人姓名" placeholder="身份证号"-->
				<input type="text" name="name" value="<?php echo $arr['user_name']; ?>" readonly="readonly" required="required">
			</div>
			<div id="a">
				身份证号
				<input type="text" name="ID" value="<?php echo $arr['ID']; ?>" required readonly>
			</div>
			<div id="a">
				联系方式
				<input type="text" name="phone" placeholder="请填写手机号" required>
			</div>
			<div id="a">
				口罩类型
				<select name="type">
					<option selected="selected">请选择</option>
					<option value="医用外科口罩">医用外科口罩</option>
					<option value="N95口罩">N95口罩</option>
					<option value="活性碳口罩">活性碳口罩</option>
				</select>


			</div>
			<div id="a">
				预约个数
				<input type="number" name="num" placeholder="请填写数量(不超过20个)" min="1" max="20" required>
			</div>
			<div id="a">
				期望到货日期
				<input type="date" name="date" placeholder="" required>
			</div>
			<div id="a">
				详细地址
				<textarea id="textarea" name="address" cols="30" rows="4" placeholder="请填写配送详细地址" required></textarea>
				<!--多行文本框-->
			</div>
			<div id="bt">
				<input type="submit" value="确定">
				<input type="reset" value="重置">
			</div>
		</form>
	</div>
	</div>
</body>
</html>

 It can be seen that the session mechanism is added to the HTML header to prevent illegal access caused by not logged in. Then query the table records from the database to match the user login information.

Back-end code implementation:

reserveorder.php processes the form submitted by the user. The user can only make an appointment once within 3 days. Otherwise, the system will tell the user the judgment result and realize it by obtaining the current timestamp for comparison. This function seems simple, but when it is implemented Encountered some small problems, such as how to compare the data type of the time obtained by querying the database table with the time currently obtained. Therefore, the time format needs to be set. See the code section for details:

//reserveorder.php
<?php
session_start();
require_once 'mysql_connect.php';
$name = $_POST[ 'name' ];
$userid = $_SESSION[ 'user_id' ];
$phone = $_POST[ 'phone' ];
$ID = $_POST[ 'ID' ];
$type = $_POST[ 'type' ];
$num = $_POST[ 'num' ];
$date = $_POST[ 'date' ];
$address = $_POST[ 'address' ];

/*reserve表*/
$query = "select * from reserve where user_id='$userid'";
$result = mysqli_query( $link, $query )or die( "打开数据库失败:" . mysqli_error() );
$arr = mysqli_fetch_array( $result );
$num_row = mysqli_num_rows( $result );

//获取当前时间
date_default_timezone_set( 'prc' ); //设置时区
$check_date = date( "Y-m-d H:i:s", strtotime( '-3 day' ) ); //获取当前时间的3天前
$date_db = $arr[ 're_date' ];

if ( $check_date < $date_db ) {
	echo "<script language='javascript'>";
	echo "alert('预约失败,用户3天内已预约!');";
	echo "window.location.href='user.php';";
	echo "</script>";
}

else {

	/*订单表*/
	$q = "select * from info"; // where user_id='$userid'";
	$r = mysqli_query( $link, $q );
	$arrary = mysqli_fetch_array( $r );
	$row_num = mysqli_num_rows( $r );
	$order_id = 100001 + $row_num;
	$statue = "已预约";


	$insert_order = "insert into info values('" . $order_id . "','" . $userid . "','" . $name . "','" . $type . "','0','" . $phone . "','" . $address . "','" . $statue . "',now()" . ")";

	$result = mysqli_query( $link, $insert_order )or die( "订单生成插入记录失败:" . mysqli_error() );

	$query = "insert into reserve(user_id,phone,ID,mask_type,r_num,ex_date,address,re_date) value('" . $userid . "','" . $phone . "','" . $ID . "','" . $type . "','" . $num . "','" . $date . "','" . $address . "',now()" . ")";

	$result = mysqli_query( $link, $query )or die( "预约记录失败:" . mysqli_error() );


	echo "<script language='javascript'>";
	echo "alert('预约成功!');";
	echo "window.location.href='myorder.php';";
	echo "</script>";
}
mysqli_free_result( $result );
mysqli_close( $link );
?>

 The main processing task of the PHP back-end is to query data table data, insert, update and delete the table, and implement simple JS pop-up window functions.

function display:

2. User view my order interface

After the reservation from the previous step is successful, it will directly jump to my order interface, as follows:

This part of the front-end is simple to implement, only one page is processed, the front-end is combined, and the query records are returned to the front-end form.

<!--myorder.php-->
<?php
session_start();
require_once 'mysql_connect.php';
if ( !$_SESSION[ 'user_id' ] ) {
	header( "Location:maskorder.php" );
	exit( '非法访问!' );
}
error_reporting( E_ERROR );

?>
<!doctype html>
<html>
<head>
	<meta charset="utf-8">
	<title>我的订单</title>
</head>
<link rel="stylesheet" type="text/css" href="css/person.css">
<style type="text/css">
	.table{
		position: relative;
		left:100px;
		width: 1200px;
	}
	a{
		text-decoration: none;
	}
	#bt{
		border: 1px solid #000000;
		border-bottom-color: #000000;
		border-radius: 5px;
	}
</style>

<body>
	<h1 align="center">我的订单</h1>
	<div>
		<form action="myorder.php" method="post" id="order">
			<table class="table" border="1">
				<thead>
					<tr>
						<th>订单号</th>
						<th>预约人姓名</th>
						<th>口罩类型</th>
						<th>分配数量</th>
						<th>预约数量</th>
						<th>电话</th>
						<th>地址</th>
						<th>订单状态</th>
						<th>预约日期</th>
						<th>期望到货日期</th>
						<th>修改</th>
					</tr>
				</thead>
				<tbody>
					<?php
						$userid = $_SESSION[ 'user_id' ];
						/*订单表、预约表连接查询*/
						$query = "select * from info,reserve where info.user_id='$userid' and info.user_id=reserve.user_id and info.re_date=reserve.re_date";
						$result = mysqli_query( $link, $query );
					
					while ($arr = mysqli_fetch_array( $result )) {
						echo "<tr>";
						echo "<td>" . $arr[ 'order_id' ] . "</td>";
						echo "<td>" . $arr[ 'user_name' ] . "</td>";
						echo "<td>" . $arr[ 'mask_type' ] . "</td>";
						echo "<td>" . $arr['allocate_num'] ."</td>";
						echo "<td>" . $arr['r_num'] ."</td>";
						echo "<td>" . $arr[ 'phone' ] . "</td>";
						echo "<td>" . $arr[ 'address' ] . "</td>";
						echo "<td>" . $arr['statue'] ."</td>";
						echo "<td>" . $arr['re_date'] ."</td>";
						echo "<td>" . $arr['ex_date'] ."</td>";
						echo "<td><a href='user_update.php?order_id=".$arr['order_id']."'>修改</a></td>";
						echo "</tr>";
					}
					?>
				</tbody>
			</table>
			<button value="返回" id="bt"><a href="user.php">返回</a></button>
		</form>
	</div>
</body>
</html>

3. The user modifies the appointment information

This part inherits the function of the appointment page and slightly modifies it. The main function is: similar to online shopping, after placing an order, only the mobile phone number and delivery address can be modified while other information is set to read-only status.

Code:

<!--user_update.php-->
<?php
//检查是否存在登录session,否则跳转登录界面
session_start();
require_once 'mysql_connect.php';
if ( !isset( $_SESSION[ 'user_id' ] ) ) {
	header( "Location:maskorder.php" );
	exit( '非法访问!' );
}
error_reporting( E_ERROR );
mysqli_query( $link, "set names 'utf8'" );

$orderid=$_GET['order_id'];
//已分配的订单用户无法再修改
 
$id = $_SESSION[ 'user_id' ];
$order_status =mysqli_query($link,"select statue from info where user_id='$id' and order_id='$orderid'");
$status = mysqli_fetch_array($order_status);
if($status['statue']!='已预约'){
	echo "<script language='javascript'>";
	echo "alert('订单已受理,无法修改!');";
	echo "window.location.href='myorder.php';";
	echo "</script>";
}
//如果用户预约了多个订单,通过自然连接,选择当前指定的订单号
$query = "select * from (users natural join reserve)natural join info where users.user_id='$id' and users.user_id=reserve.user_id and reserve.user_id=info.user_id  and info.order_id='$orderid'";

$result = mysqli_query( $link, $query );
$arr = mysqli_fetch_array( $result );
?>
<!doctype html>
<html>
<head>
	<meta charset="utf-8">
	<title>修改订单信息</title>
	<link rel="stylesheet" href="css/person.css" type="text/css">
	<style type="text/css">
		#res_form {
			/*表的宽度以及位置*/
			width: 500px;
			position: relative;
			left: 500px;
			top:100px;
		}
		
		#a {
			/*调整input输入框与文字位置,显示同一行*/
			height: 50px;
			border: 1px;
			margin: 10px;
			text-align: left;
		}
		
		#a input {
			border: 1px solid #000000;
			border-radius: 5px;
			float: right;
		}
		
		#a select {
			border: 5px;
			width: 200px;
			border-color: #000000;
			border-radius: 5px;
			float: right;
		}
		/*form input{
		text-align: left;
		margin: 10px;
	}*/
		
		#textarea {
			float: right;
			width: 200px;
		}
		
		#bt input {
			float: left;
			margin: 10px;
			width: 50px;
			background-color: #3CF;
			border-bottom-color: #000000;
			border-radius: 5px;
			position: relative;
			top: 20px;
			left: 100px;
		}
		
		#bt input:hover {
			background-color: #F00;
			color: #FFF;
			cursor: pointer;
		}
		#out{
			display: block;
			position: relative;
			left:10px;
		}
		img{
			position: relative;
			float: right;
		}
		#we{
			position: relative;
			right: 100px;
		}
		h1{
			position: absolute;
			float: left top;
			left:660px;
		}
	</style>
</head>

<body>
	<div id="res">
			<ul id="item">
				<img src="images/2.png"></img>
				<div id="out">
					<div id="we">欢迎您&nbsp;&nbsp;<?php
						echo $id;
					?>&nbsp;,</div>
				
				<li><a href="login_out.php">退出登录</a>
				</li>
				<li><a href="adm_up_user.php">修改密码</a>
				</li>
				<li><a href="myorder.php">我的订单</a>
				</li>
			</ul>
				</div>
		<h1>修改订单信息</h1>
		<div id="res_form">
			<form action="update_order.php" method="post">
				<div id="a">
					姓名
					<!--placeholder="预约人姓名" placeholder="身份证号"-->
					<input type="text" name="name" value="<?php echo $arr['user_name']; ?>" readonly="readonly" required="required">
				</div>
				<div id="a">
					身份证号
					<input type="text" name="ID" value="<?php echo $arr['ID']; ?>" required readonly>
				</div>
				<div id="a">
					联系方式
					<input type="text" name="phone" placeholder="修改手机号" required>
				</div>
				<div id="a">
					口罩类型
					<input type="text" name="mask" value="<?php echo $arr['mask_type']; ?>" required readonly>
				</div>
				<div id="a">
					预约个数
					<input type="number" name="num" value="<?php echo $arr['r_num']; ?>" min="1" max="20" required readonly>
				</div>
				<div id="a">
					期望到货日期
					<input type="date" name="date" value="<?php echo $arr['ex_date']; ?>" required readonly>
				</div>
				<div id="a">
					详细地址
					<textarea id="textarea" name="address" cols="30" rows="4" placeholder="修改配送地址" required></textarea>
					<!--多行文本框-->
				</div>
				<div id="bt">
					<input type="submit" value="确定">
					<input type="reset" value="重置">
				</div>
			</form>
		</div>
	</div>
</body>
</html>

Fourth, the administrator module

The system realizes the basic functions, and the page layout is not very beautifully designed, so the next administrator interface is like this V●ᴥ●V

The home page includes functions to modify and delete users.

1. Administrator login interface

The back-end processing is shown here, and the front-end part is easier to implement. Here is a more special function, using SQL language to achieve fuzzy query , the demonstration is as follows:

<!--admin.php-->
<?php
//检查是否存在登录session,否则跳转登录界面
session_start();
require_once 'mysql_connect.php';
if ( !isset( $_SESSION[ 'work_id' ] ) ) {
	header( "Location:maskorder.php" );
	exit( '非法访问!' );
}
error_reporting( E_ERROR );
mysqli_query( $link, "set names 'utf8'" );
?>
<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<!--link type="text/css" href="css/main.css" rel="stylesheet"-->
	<title>管理员</title>
	<link type="text/css" href="css/person.css" rel="stylesheet">
	<style type="text/css">
		#store {
			float: left;
			position: absolute;
			left: 700px;
			top: -200px;
		}
		
		.login1 {
			position: relative;
			top: 100px;
		}
	</style>
</head>

<body>
	<div id="page">
		<div id="out">

			<ul id="item">
				<li><a href="adm_order.php">审核订单</a>
				</li>
				<li><a href="login_out.php">退出登录</a>
				</li>
			</ul>
		</div>
		<h1 align="center">管理员登录界面</h1>
		<div class="login1">
			<form action="admin.php" method="post">
				<select name="item">
					<option selected>请选择查询条件</option>
					<option value="user_id">账号</option>
					<option value="user_name">姓名</option>
					<option value="ID">身份证号</option>
				</select>
				<input type="text" name="val">
				<button type="submit" class="btn btn-info">查询</button>
				<table class="table" border="1">
					<thead>
						<tr>
							<th>账号</th>
							<th>密码</th>
							<th>姓名</th>
							<th>身份证号</th>
							<th>注册时间</th>
							<th>修改</th>
						</tr>
					</thead>
					<tbody>
						<?php
						$item = $_POST[ 'item' ];
						$val = $_POST[ 'val' ];

						if ( !$val ) {
							$sql = "select * from users order by date desc";
						} else {
							$sql = "select * from users where $item like '%$val%' order by date desc";
						}
						mysqli_query( $link, "set names 'utf8'" );
						$res = mysqli_query( $link, $sql );
						while ( $arr = mysqli_fetch_array( $res ) ) {
							echo "<tr>";
							echo "<td>" . $arr[ 'user_id' ] . "</td>";
							echo "<td>" . $arr[ 'pwd' ] . "</td>";
							echo "<td>" . $arr[ 'user_name' ] . "</td>";
							echo "<td>" . $arr[ 'ID' ] . "</td>";
							echo "<td>" . $arr[ 'date' ] . "</td>";
							echo "<td><a href='adm_up_user.php?user_id=" . $arr[ 'user_id' ] . "'>修改</a>/<a href='admin.php?user_id=" . $arr[ 'user_id' ] . "'>删除</a></td>";
							echo "</tr>";
						}

						?>
					</tbody>
				</table>
			</form>
			<div id="store">
				<h2 align="center">口罩信息表</h2>
				<table border="1">
					<tr>
						<th>口罩类型</th>
						<th>仓库</th>
						<th>剩余数量</th>
						<th>单位价格</th>
					</tr>
					<?php
					$mask = mysqli_query( $link, "select * from mask" );

					while ( $maskarr = mysqli_fetch_array( $mask ) ) {
						echo "<tr>";
						echo "<td>" . $maskarr[ 'mask_type' ] . "</td>";
						echo "<td>" . $maskarr[ 'store' ] . "</td>";
						echo "<td>" . $maskarr[ 'remain_num' ] . "</td>";
						echo "<td>" . $maskarr[ 'price' ] . "</td>";
						echo "</tr>";
					}
					?>
				</table>
			</div>
			<?php
			$delete = $_GET[ 'user_id' ];
			mysqli_query( $link, "delete from users where user_id='$delete'" )or die( "删除失败" );
			?>

		</div>
	</div>
</body>
</html>

 2. View user reservation orders

Attentive friends can see that there is a button to review the order in the upper right corner of the administrator interface. This is the entrance to view the user's reservation order. After entering, you can see this.

The back-end implements querying data from the database and returning to the front-end. In addition, it is important to note that the administrator can only review the reserved orders to prevent misoperations. Multiple review orders and assign them, so the back-end needs to do some restrictions and wrong operations remind.

Specific code for back-end implementation:

<?php
//检查是否存在登录session,否则跳转登录界面
session_start();
require_once 'mysql_connect.php';
if ( !isset( $_SESSION[ 'work_id' ] ) ) {
	header( "Location:maskorder.php" );
	exit( '非法访问!' );
}
error_reporting( E_ERROR );
mysqli_query( $link, "set names 'utf8'" );
$id = $_SESSION[ 'work_id' ];
$order_id = $_GET['order_id'];

//检查订单是否为预约状态
$ch_re =mysqli_query($link,"select * from info where order_id='$order_id'");
$ch_arr= mysqli_fetch_array($ch_re);
if($ch_arr['statue']!='已预约'){
	echo "<script language='javascript'>";
	echo "alert('该订单已经审核过!');";
	echo "window.location.href='adm_order.php';";
	echo "</script>";
}
//如果用户预约了多个订单,通过自然连接,选择当前指定的订单号以及用户信息进行处理
$query = "select * from (users natural join reserve)natural join info where users.user_id=reserve.user_id and reserve.user_id=info.user_id  and info.order_id='$order_id'";

$result = mysqli_query( $link, $query ) or die("出错啦!");
$arr = mysqli_fetch_array( $result );
$address = $arr['address'];

$de = "select * from delivers";
$de_re=mysqli_query($link,$de);

?>

 The legal review order enters the interface as follows. The administrator can operate the order information only including the number of masks allocated, the distribution of couriers, and the rest are read-only, so as to ensure the correctness of the user's reservation information and prevent the administrator from modifying user information.

3. Modify/delete user information

<?php
session_start();
require_once 'mysql_connect.php';
if (isset($_SESSION['work_id'])) {
    $id = $_GET['user_id'];
	$useinfo=mysqli_query($link,"select * from users where user_id='$id'");
	$userarr = mysqli_fetch_array($useinfo);
	error_reporting(E_ERROR);
}
elseif(isset($_SESSION['user_id'])){
	$id = $_SESSION['user_id'];
	$useinfo=mysqli_query($link,"select * from users where user_id='$id'");
	$userarr = mysqli_fetch_array($useinfo);
	error_reporting(E_ERROR);
}
else{
	header("Location:maskorder.php");
    exit('非法访问!');
}

?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="css/main.css">
<title>修改用户信息</title>
<body>
<div class="main">
    <h2 align="center">修改用户信息</h2>
     <div id="page">
       <div class="login1">
		<form action="adm_up_user_sql.php" id="form1" method="post">
			<input type="text" name="name" class="name" value="<?php echo $userarr['user_id'];?>" required>
			<input type="text" name="username" class="username" value="<?php echo $userarr['user_name'];?>" required>
			<input type="text" name="ID" class="ID" value="<?php echo $userarr['ID'];?>" required>
			<input type="password" name="password" class="password" placeholder="修改密码" required>
			<div class="clear"></div>
			<input type="submit" value="修改" >
		</form>
       </div>
     </div>
</div>
</body>
</html>

Five, the courier module

1. The courier logs into the distribution system

Couriers can check their orders according to the order status

 Use the view to extract part of the information from the order table to meet the delivery requirements and ensure user information security. The method is similar before the front-end page iteration.

Page form processing, using the previously created view:

					<?php
					$search=$_POST['item'];
					if(!$search){
						$query = "select * from deli_order,allocate where deli_order.order_id=allocate.order_id and deliver_id='$id'";
					}
					/*订单视图、接关单表连接查询,只能看到分配到当前快递员的订单*/
					else{
						$query = "select * from deli_order,allocate where deli_order.order_id=allocate.order_id and deliver_id='$id' and deli_order.statue='$search'";
					}
						
					$result = mysqli_query( $link, $query );

					while ( $arr = mysqli_fetch_array( $result ) ) {
						
					//快递员查看订单接关单时间
						$q_take="select * from take where order_id='".$arr['order_id'] ."'";
						$r_take=mysqli_query($link,$q_take);
						$arr_take=mysqli_fetch_array($r_take);
						echo "<tr>";
						echo "<td>" . $arr[ 'order_id' ] . "</td>";
						echo "<td>" . $arr[ 'mask_type' ] . "</td>";
						echo "<td>" . $arr[ 'allocate_num' ] . "</td>";
						echo "<td>" . $arr[ 'phone' ] . "</td>";
						echo "<td>" . $arr[ 'address' ] . "</td>";
						echo "<td><font color='red'>" . $arr[ 'statue' ] . "</font></td>";
						echo "<td>" . $arr[ 're_date' ] . "</td>";
						echo "<td>" . $arr_take[ 'take_date' ] . "</td>";
						echo "<td>" . $arr_take[ 'finish_date' ] . "</td>";
						echo "<td><a href='de_jie.php?order_id=".$arr['order_id']."'>接单</a>/<a href='de_guan.php?order_id=".$arr['order_id']."'>关单</a></td>";
						echo "</tr>";
						
					}
					?>

2. Take orders

The courier can only receive orders in the assigned status, which is reflected in the code, uses the judgment statement to determine the status of the selected order, and returns the corresponding prompt. 

<?php
session_start();
require_once('mysql_connect.php');
if(!$_SESSION['deliver_id']){
	header("Location:maskorder.php");
	exit("非法访问!");
}
error_reporting(E_ERROR);
$deliverid=$_SESSION['deliver_id'];
$orderid=$_GET['order_id'];
//查询快递员姓名
$de_info = mysqli_query($link,"select * from delivers");
$arr_de = mysqli_fetch_array($de_info);

//判断是否已经接过该订单
$jie = "select * from take where order_id='$orderid'";
$jie_re = mysqli_query($link,$jie);
$jie_row = mysqli_num_rows($jie_re);
if($jie_row){
	echo "<script language='javascript'>";
	echo "alert('已经接过此订单,请勿重复操作!');";
	echo "window.location.href='deliver.php';";
	echo "</script>";	
}

else{
	
	//将配送员信息插入接关单表
	$in_take = "insert into take values('".$deliverid."','".$orderid."','".$arr_de['deliver_name']."',now(),null)";
	mysqli_query($link,$in_take) or die("接单失败".mysqli_error());
	//更新订单表中的状态信息,只能接已分配的订单
	$de_or_st="update info set statue='已接单' where order_id='$orderid'";
	mysqli_query($link,$de_or_st) or die("接单失败".mysqli_error());

	echo "<script language='javascript'>";
	echo "alert('接单成功!');";
	echo "window.location.href='deliver.php';";
	echo "</script>";
}


mysqli_free_result($de_info);
mysqli_close($link);
?>

3. Close the order

The courier can only close the order that has been received, indicating that the delivery is completed, which is the same as the logic of receiving the order.

<?php
session_start();
require_once('mysql_connect.php');
if(!$_SESSION['deliver_id']){
	header("Location:maskorder.php");
	exit("非法访问!");
}
error_reporting(E_ERROR);
$deliverid=$_SESSION['deliver_id'];
$orderid=$_GET['order_id'];


//更新订单表中的状态信息,只能关已接单的订单
$jie="select * from info where order_id='$orderid'";
$jie_re = mysqli_query($link,$jie);
$jie_arr=mysqli_fetch_array($jie_re);

if($jie_arr['statue']=='已分配'){
	echo "<script language='javascript'>";
	echo "alert('未接该订单,无法关单!');";
	echo "window.location.href='deliver.php';";
	echo "</script>";
}
elseif($jie_arr['statue']=='已关单'){
	echo "<script language='javascript'>";
	echo "alert('该订单已关闭,请勿重复操作!');";
	echo "window.location.href='deliver.php';";
	echo "</script>";
}
else{
	//更新接关单表,关单状态
	//关单时间
	$up_time = "update take set finish_date=now() where order_id='$orderid'";

	mysqli_query($link,$up_time) or die("关单时间错误".mysqli_error());
	
	$de_or_st="update info set statue='已关单' where order_id='$orderid' and statue='已接单'";
	mysqli_query($link,$de_or_st) or die("关单失败".mysqli_error());

	echo "<script language='javascript'>";
	echo "alert('关单成功!');";
	echo "window.location.href='deliver.php';";
	echo "</script>";
}
mysqli_free_result($jie_re);
mysqli_close($link);
?>

Six, system implementation summary

1. Security

When the system enters the debugging stage, it is found that the page can be accessed directly without logging in, so it is necessary to add a verification mark to the head of each page. Once it is found that there is no logged-in session , jump directly to the login page. The user is required to enter an account and password to log in. The specific implementation is as follows:

<?php
session_start();
if((!isset($_SESSION['work_id'])) || (!isset($_SESSION['user_id']))){
header("Location:maskorder.php");
exit;
}
?>

In addition, the courier logs in to the system to view the orders that have been assigned to him. For the safety of user information, a view of the order data table is established to retain the user information required by the courier during the delivery process. 

2. User appointment time

For the operation of user reservation, in order to save the specific time to the reservation order data table for the back-end administrator to view the user reservation information, here I encountered a problem, how to get the current time and insert it into the database, and later use the mysql database system function now () to get the current timestamp.

3. The front and back ends interact with the database

In the design of the database application system this time, another difficulty was encountered: how to process the data returned by the front-end form and interact with the mysql database. I used the back-end developed PHP to connect to the database , process the data returned by the front-end form, and perform a series of operations on the database (query, modify, insert, delete) through the sql language . This stage takes a relatively long time, and I realized it in the early stage. Interaction of basic functions, some detailed problems were discovered later in the interaction process . For example, the user can only modify the appointment information when the order is processed by the administrator , the administrator cannot review the order repeatedly , and the courier can only close the order and the order that has been received. I can’t repeat the details of receiving orders and closing orders . I keep thinking about these details in the process of testing system functions to ensure that the system has the most basic and reasonable functions and requirements. This also makes me realize the various design of database application systems. Need to pay attention to, improving functional requirements is the focus of a development process.

Series of articles:

  1. Mask appointment management system-database design (front-end + PHP + MySQL)
  2. Mask appointment management system-system website implementation (front-end + PHP + MySQL)

My CSDN blog: https://blog.csdn.net/Charzous/article/details/108619341 

Guess you like

Origin blog.csdn.net/Charzous/article/details/108619341