-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatus.php
More file actions
83 lines (72 loc) · 2.35 KB
/
status.php
File metadata and controls
83 lines (72 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
session_start();
include("connection.php");
include("functions.php");
$user_data = check_login($con);
?>
<!DOCTYPE html>
<html>
<head>
<title>My database project</title>
<link rel="stylesheet" href="tabs.css">
<link rel="stylesheet" href="float.css">
</head>
<body>
<!-- serach order, show staus
check status add status -->
<div id="box">
<form method="post">
<input id="text" type="text" name="search_id" placeholder="Enter the order ID">
<input id="button" type="submit" name="Search" value="Search"><br>
</form>
</div>
<div style = "padding: 16px; background-color: #FFF8DC;">
<?php
if($_SERVER['REQUEST_METHOD'] == "POST" && isset($_POST['Search'])) {
$search_id = $_POST['search_id'];
$query = "select count(*) as cnt from states where states.order_id='$search_id'";
$result = mysqli_query($con, $query);
$data = mysqli_fetch_assoc($result);
$data = $data['cnt'];
$cur_state = 1;
if($data == 2) {
echo 'error message';
}
else {
if( $data==0 ){
$cur_state = 1;
$query = "select id as sell_id from sell where sell.order_id='$search_id'";
$result = mysqli_query($con,$query);
$addr_id = mysqli_fetch_assoc($result);
$addr_id = $addr_id['sell_id'];
echo 'Delivering';
}else if( $data==1 ){
$cur_state = 2;
$query = "select id as buy_id from buy where buy.order_id='$search_id'";
$result = mysqli_query($con,$query);
$addr_id = mysqli_fetch_assoc($result);
$addr_id = $addr_id['buy_id'];
echo 'arrived';
}
$query = "select addr as address from person where person.id='$addr_id'";
$result = mysqli_query($con,$query);
$address = mysqli_fetch_assoc($result);
$address = $address[ 'address' ];
$id=random_num(20);
$query = "insert into trans (id,cur_state,addr) values ('$id','$cur_state','$address')";
mysqli_query($con, $query);
$query = "select trans_id from trans where trans.id='$id'";
$result= mysqli_query($con, $query);
$result = mysqli_fetch_assoc($result);
$trans_id = $result['trans_id'];
$query = "insert into states(order_id,trans_id) values('$search_id','$trans_id')";
mysqli_query($con,$query);
$id=$user_data['id'];
$query = "insert into work(id,trans_id) values('$id','$trans_id')";
mysqli_query($con,$query);
die;
}
}
?>
</div>
</body>