-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroot.php
More file actions
107 lines (94 loc) · 3.47 KB
/
root.php
File metadata and controls
107 lines (94 loc) · 3.47 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?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">
</head>
<body>
<!-- modify position -->
<div style = "padding: 16px; background-color: #FAEBD7">
<h3 style="color:#4D0000">Modify Position</h3>
<?php
if($_SERVER['REQUEST_METHOD'] == "POST" && isset($_POST['ModPosition'])) {
$modify_id = $_POST['modify_id'];
$pos_num = 0;
if( isset($_POST['member']) ) { $pos_num += 1; }
if( isset($_POST['driver']) ) { $pos_num += 2; }
if( isset($_POST['analyzer']) ) { $pos_num += 4; }
if( isset($_POST['employee']) ) { $pos_num += 8; }
if( isset($_POST['root']) ) { $pos_num += 16;}
$query = "update person set position = '$pos_num' where person.id = '$modify_id';";
mysqli_query($con, $query);
header("Refresh:0");
die;
}
?>
<form method="post">
<input id="text" type="text" name="modify_id" placeholder="Enter the user ID"><br><br>
<input id="checkbox" type="checkbox" checked="checked" name="member" value="member />
<label for="member"> member </label>
<input id="checkbox" type="checkbox" name="driver" value="driver">
<label for="member"> driver </label>
<input id="checkbox" type="checkbox" name="analyzer" value="analyzer">
<label for="member"> analyzer </label>
<input id="checkbox" type="checkbox" name="employee" value="employee">
<label for="member"> employee </label>
<input id="checkbox" type="checkbox" disabled="disabled" name="root" value="root">
<label for="member"> root </label>
<br><br>
<input id="button" type="submit" name="ModPosition" value="submit">
</form></div>
</div>
<br>
<!-- delete Person -->
<div style = "padding: 16px; background-color: #FAEBD7;">
<h3 style="color:#4D0000">Delete User</h3>
<?php
if($_SERVER['REQUEST_METHOD'] == "POST" && isset($_POST['DeleteUser'])) {
$delete_id = $_POST['on_delete_id'];
$query = "delete from person where person.id = '$delete_id';";
mysqli_query($con, $query);
header("Refresh:0");
die;
}
?>
<form method="post">
<input id="text" type="text" name="on_delete_id" placeholder="Enter the User ID"><br><br>
<input id="button" type="submit" name="DeleteUser" value="Delete">
</form>
</div>
<br>
<!-- add product -->
<div style = "padding: 16px; background-color: #FAEBD7;">
<?php
if($_SERVER['REQUEST_METHOD'] == "POST" && isset($_POST['AddProduct'])) {
$seller_id = $_POST['add_sell_id'];
$p_name = $_POST['add_p_name'];
$p_price = $_POST['add_p_price'];
$query = "insert into product (p_name,cost) values ('$p_name','$p_price')";
mysqli_query($con, $query);
$query = "select * from product where p_name = '$p_name' and cost = '$p_price'";
$result = mysqli_query($con, $query);
$data = mysqli_fetch_assoc($result);
$data = $data['product_id'];
$query = "insert into own (id, product_id) values ('$seller_id','$data')";
mysqli_query($con, $query);
header("Refresh:0");
die;
}
?>
<h3 style="color:#4D0000">Add Product</h3>
<form method="post">
<input id="text" type="text" name="add_sell_id" placeholder="Enter the seller ID"><br><br>
<input id="text" type="text" name="add_p_name" placeholder="Enter the product name"><br><br>
<input id="text" type="text" name="add_p_price" placeholder="Enter the product price"><br><br>
<input id="button" type="submit" name="AddProduct" value="Add">
</form>
</div>
</body>