-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuser.php
197 lines (150 loc) · 5.48 KB
/
user.php
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<?php
// 数据库连接信息
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "bowwow";
// 创建数据库连接
$conn = new mysqli($servername, $username, $password, $dbname);
// 检查连接是否成功
if ($conn->connect_error) {
die("Failed " . $conn->connect_error);
}
// 查询所有商品
$sql = "SELECT * FROM user";
$result = $conn->query($sql);
// 处理表单提交
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// 处理添加商品请求
if (isset($_POST["add_user"])) {
$name = $_POST["name"];
$price = $_POST["price"];
$description = $_POST["description"];
$sql = "INSERT INTO user (name, price, description) VALUES ('$name', '$price', '$description')";
if ($conn->query($sql) === TRUE) {
echo "scuessful";
} else {
echo "Failed: " . $conn->error;
}
}
// 处理编辑商品请求
if (isset($_POST["edit_user"])) {
$id = $_POST["id"];
$name = $_POST["name"];
$price = $_POST["price"];
$description = $_POST["description"];
$sql = "UPDATE users SET name='$name', price='$price', description='$description' WHERE id=$id";
if ($conn->query($sql) === TRUE) {
echo "scuessful";
} else {
echo "Failed: " . $conn->error;
}
}
// 处理删除商品请求
if (isset($_POST["delete_category"])) {
$id = $_POST["id"];
$sql = "DELETE FROM users WHERE id=$id";
if ($conn->query($sql) === TRUE) {
echo "scuessful";
} else {
echo "Failed: " . $conn->error;
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>User Management</title>
<!-- Remote style sheet -->
<link rel="stylesheet" href="https://unpkg.com/mdui@1.0.2/dist/css/mdui.min.css"/>
<script src="https://unpkg.com/mdui@1.0.2/dist/js/mdui.min.js"></script>
<!-- Local style sheet relative to workspace folder -->
<link rel="stylesheet" href="/style.css">
<script src="css/theme.css"></script>
<!-- Local style sheet relative to this file -->
<link rel="stylesheet" href="theme.css">
<!-- Embedded style sheet -->
<style>
table.center{
margin:10% 10% -10% -20%;
width:115%;
border-collapse:collapse;
text-align: center;
}
table.center th, table.center td {
padding: 8px;
border-bottom: 1px solid #ddd;
}
table.center th{
background-color: #D8CCC4;
}
.cell-content{
display:flex;
align-items:center;
}
.info{
display:flex;
flex-direction: column;
}
h2{
margin-left: -20%;
}
div.search_clearfix{
float:right;
margin-right:calc(5%);
margin-bottom:calc(2%);
}
</style>
</head>
<body>
<?php include ("include/sidebar.php");?>
<div class="mdui-drawer-body-left" id="body" >
<!--主题-->
<h2>User List</h2>
<!-- SEARCHING -->
<div class="margin" id="page_style">
<div class="operation clearfix">
<span class="submenu">
<div class="search_clearfix">
<label class="label_name">Order Searching:</label><input name="" type="text" class="form-control col-xs-6"/><button class="mdui-btn mdui-btn-raised mdui-ripple mdui-color-amber-100" onclick="" type="button" ><i class="fa fa-search"></i> Search</button>
</div>
</div>
<!--列表展示-->
<h3>
<div class="list_Exhibition margin-sx">
<table class="table table_list table_striped table-bordered center" id="sample-table">
<tr>
<th width="5%"><label><input type="checkbox" class="ace"><span class="lbl"></span></label></th>
<th width="10%">ID</th>
<th width="25%">User</th>
<th width="5%">Member</th>
<th width="20%">Email</th>
<th width="10%">Payment</th>
<th width="10%">Last Online Time</th>
<th width="15%">Operation</th>
</tr>
<?php
// 在这里添加您的PHP代码
while($user=$result->fetch_assoc()){
echo "<table class='table table_list table_striped table-bordered center'>";
echo "<tr>";
echo '<td width="5%">'.'<label>'.'<input type="checkbox" class="ace"><span class="lbl">'.'</span>'.'</label>'.'</td>';
echo '<td width="10%">'.$user['id'].'</td>';
echo '<td width="25%"><div class="cell-content"><img src="images/user_avatar/'.$user['image_path'].'"alt="'.$user['image_path'].'"width="100px"height="100px"></div><div class="info"><div>'.$user['username'].'</div><div>'.$user['phone'].'</div></div></td>';
echo '<td width="5%">' . ($user['is_member'] == 0 ? 'No' : ($user['is_member'] == 1 ? 'Yes' : '')) . '</td>';
echo '<td width="20%">'.$user['email'].'</td>';
echo '<td width="10%">' . ($user['payment'] == 0 ? 'PayPal' : ($user['payment'] == 1 ? 'Credit Card' : ($user['payment'] == 2 ? 'Other' :''))) . '</td>';
echo '<td width="10%">'.$user['last_online'].'</td>';
echo '<td width="15%"><a href="user_information.php?ID='.$user['id'].'">Edit</a><br/> ';
echo '<a href="Delete.php?cate=user&id='.$user['id'].'">Delete</a></td>';
echo "</tr>";
echo "</table>";
}
?>
</table>
</div>
</h3>
</div>
</body>
</html>