-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin_user.php
204 lines (175 loc) · 6.44 KB
/
admin_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
198
199
200
201
202
203
204
<?php
include("admin.php");
?>
<?php $db_host = 'localhost';
$db_user = 'root';
$db_pwd = '';
$database = 'online_art_gallery_database_final';
$table = 'user';
$conn = mysqli_connect($db_host, $db_user, $db_pwd,$database);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
?>
<?php
if(isset($_POST['submit'])) {
$id = $_POST['deleteuser'];
$delete ="DELETE FROM user WHERE user_id = '$id' ";
if (mysqli_query($conn, $delete)) {
echo "Record deleted successfully";
} else {
echo "Error updating record: " . mysqli_error($conn);
}
} ?>
<html>
<head>
<title>MySQL Table Viewer</title>
<style type="text/css">
.bodymargin{
margin:1000px 100px 10px 40px;
}
.head-table {
font-size: 40px;
font-family: "Yu Gothic UI Light";
color:#2a8048;
position: absolute;
top: 165px;
left: 50px;
}
.head-user{
font-variant: small-caps;
font-size: 50px;
font-family: "Yu Gothic UI Light";
color: rgb( 00, 00, 00 );
position: absolute;
top: 150px;
left: 210px;
z-index: 19;
}
.hr{
position: absolute;
border: 1px solid #2a8048;
top: 235px;
margin-left: -26px;
width: 1150px;
left: 73px;
}
.deletebar{
border-radius: 8px;
border: 1px solid none;
background-color: #fff;
position: absolute;
top: 6px;
width:150px;
height: 30px;
}
.delbutton{
text-decoration: none;
cursor: pointer;
border-radius: 8px;
padding: 5px 8px 5px 8px;
font-family: "Yu Gothic UI Light";
color: white;
font-size: 13px;
background-color: #FF0017;
position: relative;
top:97px;
left:58px;
}
.editbtn{
border-radius: 8px;
padding: 5px 8px 5px 8px;
background-color: #234;
cursor: pointer;
text-decoration:none;
color:white;
font-family: "Yu Gothic UI Light";
color:white;
font-size: 13px;
position: relative;
top:97px;
left:0px;
width: 60px;
height: 25px;
bottom: 3px;
}
.rowdesign:nth-child(odd){
background-color: #ffffff;
position :relative ;
top :400px;
}
.table-head{
font-weight: bold;
position :relative ;
top :400px;
}
.table-head .table-data{
padding:10px;
text-align: center;
position :relative ;
top :100px;
border-bottom: 1px solid none;
font-family: "Yu Gothic UI Light";
}
/* .table-head:hover{
background-color: #000000;
position :relative ;
top :0px;
}*/
</style>
</head>
<body class="bodymargin">
<script>
function YNconfirm() {
if (window.confirm('Are you sure you want to delete This Account? (WARNING ALL THE DATA IN THIS ACCOUNT WILL BE DELETED INCLUDING ORDERS, ARTWORKS, RATINGS OF THIS USER AND COMMENTS)'))
{
return true;
}
else
return false;
};
</script>
<form action = "admin_user.php" method="POST">
<?php
// sending query
$result = mysqli_query($conn,"SELECT USER_ID, USERNAME, PASSWORD, USER_FNAME, USER_MNAME, USER_LNAME, USER_GENDER, USER_BDAY, USER_CONTACT FROM user WHERE user_type = 'Artist' OR user_type = 'Customer'");
if (!$result) {
die("Query to show fields from table failed");
}
if(mysqli_num_rows($result) <=0){
echo '<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><h1 align="Center">No User Accounts Created</h1>';
}
else{
$fields_num = mysqli_num_fields($result);
echo '<p> <h1 class="head-table" >TABLE: </h1>
<h1 class="head-user" >User</h1><br> <hr class="hr" style="border-bottom: 2px solid #2a8048;">
</p>';
echo '<table style="position: absolute; top:180px;left:70px;border-collapse: collapse; width: 50px;"><tr class="table-head" >';
// printing table headers
for($i=0; $i<$fields_num; $i++){
$field = mysqli_fetch_field($result);
echo '<td class="table-data" style="background-color:#308f3f; color:white;">'.$field->name.'</td>';
}
echo '<td class="table-data" style="background-color:#308f3f; color:white;"> ACTION </td>';
echo "</tr>\n";
// printing table rows
while($row = mysqli_fetch_array($result)){
echo '<tr class="rowdesign table-head">';
echo '<td class="table-data">'.$row[0].'</td>
<td class="table-data">'.$row[1].'</td>
<td class="table-data">'.$row[2].'</td>
<td class="table-data">'.$row[3].'</td>
<td class="table-data">'.$row[4].'</td>
<td class="table-data">'.$row[5].'</td>
<td class="table-data">'.$row[6].'</td>
<td class="table-data">'.$row[7].'</td>
<td class="table-data">0'.$row[8].'</td>';
echo '<td><a class="editbtn" href =edituser.php?id='.$row[0].'> Modify</a> <a class="delbutton" href="admin_deleteuser.php?id='.$row[0].'" onclick="return(YNconfirm());">Delete</a></td>';
echo "</tr>\n";
}
}
mysqli_free_result($result);
?>
</form>
</body>
</html>