-
Notifications
You must be signed in to change notification settings - Fork 14
/
product_edit.php
381 lines (313 loc) · 9.18 KB
/
product_edit.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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
<!DOCTYPE>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<head><link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css" integrity="sha384-oS3vJWv+0UjzBfQzYUhtDYW+Pj2yciDJxpsK1OYPAYjqT085Qq/1cq5FLXAZQ7Ay" crossorigin="anonymous"></head>
<style type="text/css">
@charset "UTF-8";
@import url(https://fonts.googleapis.com/css?family=Open+Sans:300,400,700,400italic);
html {
box-sizing: border-box;
}
body {
background: #f1f2f7;
font-family: "Open Sans", arial, sans-serif;
color: darkslategray;
}
header[role ="banner"] h1 {
margin: 0;
font-weight: 300;
padding: 1rem;
}
header[role="banner"] {
background: white;
box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.15);
position: fixed;
top: 0;
left: 0;
width: 100%;
z-index: 99;
height: 75px;
padding-right: 0.6em;
color: red;
}
header[role="banner"] .utilities {
position: absolute;
top: 0;
right: 0;
background: transparent;
color: darkslategray;
width: auto;
}
header[role="banner"] .utilities li {
display: inline-block;
}
header[role="banner"] .utilities li a {
padding: 0.5em 1em;
}
a {
text-decoration: none;
color: inherit;
}
ul,
li {
list-style-type: none;
margin: 0;
padding: 0;
}
@media screen and (min-width: 600px)
{
nav[role="navigation"] {
position: fixed;
width: 200px;
top: 75px;
bottom: 0px;
left: 0px;
}
main[role="main"]
{
margin: 75px 0 40px 200px;
}
.panel {
margin: 2% 0 0 2%;
float: left;
width: 96%;
}
@media screen and (min-width: 900px) {
.panel
{
width: 47%;
clear: none;
}
.panel.important {
width: 96%;
}
.panel.secondary
{
width: 23%;
}
.logout
{
color:red;
}
.rempro
{
color:red;
display: inline-block;
margin-top: -2px;
}
.imgpro
{
margin-top: 5%;
height: 250px;
width: 250px;
border: 1px solid black;
}
table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 100%;
}
td, th {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}
tr:nth-child(even) {
background-color: #dddddd;
}
#search_options
{
background-color: darkslategrey;
border: none;
border-bottom: solid 4px black;
padding: 0.7em 3em;
margin: 1em 0;
color:white;
text-shadow: 0 -1px 0 #e60000;
font-size: 1.1em;
font-weight: bold;
display: inline-block;
width: auto;
}
form input,
form textarea,
form select {
width: 100%;
display: block;
border: solid 1px #dde;
padding: 0.5em;
}
form label,
form legend {
display: block;
margin: 1em 0 0.5em;
}
form input[type = "submit"]
{
background: #ff1a1a;
border: none;
border-bottom: solid 4px #e60000;
padding: 0.7em 3em;
margin: 1em 0;
color: white;
text-shadow: 0 -1px 0 #e60000;
font-size: 1.1em;
font-weight: bold;
display: inline-block;
width: auto;
-webkit-border-radius: 0.5em;
-moz-border-radius: 0.5em;
-ms-border-radius: 0.5em;
border-radius: 0.5em;
}
</style>
<script type="text/javascript">
function showfield(name)
{
if(name == "upn")
{
document.getElementById('dupr').style.display="none";
document.getElementById('dude').style.display="none";
document.getElementById('duim').style.display="none";
document.getElementById('dupn').style.display="block";
}
else if(name == "upr")
{
document.getElementById('dupn').style.display="none";
document.getElementById('dude').style.display="none";
document.getElementById('duim').style.display="none";
document.getElementById('dupr').style.display="block";
}
else if(name == "ude")
{
document.getElementById('dupr').style.display="none";
document.getElementById('dupn').style.display="none";
document.getElementById('duim').style.display="none";
document.getElementById('dude').style.display="block";
}
else if(name == "uim")
{
document.getElementById('dupr').style.display="none";
document.getElementById('dude').style.display="none";
document.getElementById('dupn').style.display="none";
document.getElementById('duim').style.display="block";
}
}
function starting()
{
document.getElementById('dupr').style.display="none";
document.getElementById('dude').style.display="none";
document.getElementById('duim').style.display="none";
document.getElementById('dupn').style.display="block";
}
function checkdisable(texbox,submitbutton)
{
var tb=document.getElementById(texbox).value;
if(tb == "")
{
document.getElementById(submitbutton).disabled = true;
}
else
{
document.getElementById(submitbutton).disabled = false;
}
}
</script>
<header role="banner">
<h1> <i style="color:#332F2F;" class="fas fa-user-lock"></i> Admin Portal</h1>
<ul class="utilities">
<br>
<li class="users">
</a></li>
<li class="logout"><a href="logout.php"><i class="fas fa-sign-out-alt" style =" margin-right: 4px"></i>Log Out</a></li>
</ul>
</header>
<?php
ini_set('error_reporting', 'E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR');
include 'connection.php';
$conn = OpenCon();
session_start();
if($_SESSION["admin"] === false)
{
echo '<script>alert("You are not admin. Only admins can view this page.");</script>';
echo '<script>window.history.back();</script>';
exit;
}
$product_id = $_GET['productid'];
$query = 'SELECT products.icon_name,products.product_id,products.product_name,products.category_id,category_name,price,date_added,description FROM products,category WHERE (products.category_id=category.category_id) AND (product_id = '.$product_id.')';
$result= mysqli_query($conn,$query);
if($result->num_rows == 0)
{
echo '<script>alert("Invalid Product ID");window.history.back();</script>';
exit;
}
else
{
$row = $result->fetch_assoc();
$image=$row['icon_name'];
echo '<img class = "imgpro" src="images/'.$image.'" alt="Image">';
echo '<br><br>';
echo '<table>';
echo '<tr>';
echo '<td> Product ID </td> <td> '.$product_id.'</td>';
echo '</tr>';
echo '<tr>';
echo '<td> Product Name </td> <td> '.$row['product_name'].'</td>';
echo '</tr>';
echo '<tr>';
echo '<td>Category ID</td> <td> '.$row['category_id'].'</td>';
echo '</tr>';
echo '<tr>';
echo '<td style = "color:black;">Category Name</td> <td>'.$row['category_name'].'<br>';
echo '</tr>';
echo '<tr>';
echo '<td>Price</td> <td> Rs '.$row['price'].'<br>';
echo '</tr>';
echo '<tr>';
echo '<td>Description</td> <td>'.$row['description'].'<br>';
echo '</tr>';
echo '</table>';
}
?>
<body onload="starting()">
<select name="search_options" id="search_options" onchange="showfield(this.options[this.selectedIndex].value)">
<option value="upn">Update Product Name</option>
<option value="upr">Update Price</option>
<option value="ude">Update Description</option>
<option value="uim">Update Image</option>
</select>
</br> </br>
<div id="dupn">
<form action=<?php echo 'updateproductname.php?productid='.$product_id.'&'?> method="POST">
<input type="text" name="update_pn" id="epn" required placeholder="Enter Product Name" onchange="checkdisable('epn','idupn')" onkeyup="checkdisable('epn','idupn')"> </br>
<input type="submit" id="idupn" disabled value="Update Product Name" />
</form>
</div>
<div id="dupr">
<form action=<?php echo 'updateproductprice.php?productid='.$product_id.'&'?> method="POST">
<input type="number" min="0" name="update_pp" id="epp" required placeholder="Enter Product Price" onchange="checkdisable('epp','idupp')" onkeyup="checkdisable('epp','idupp')"> </br>
<input type="submit" id="idupp" disabled value="Update Product Price" />
</form>
</div>
<div id="dude">
<form action=<?php echo 'updateproductdescription.php?productid='.$product_id.'&'?> method="POST">
<textarea rows = "10" cols = "16" id="epd" required name = "descrip" placeholder="Enter Product Description" onchange="checkdisable('epd','idude')" onkeyup="checkdisable('epn','idupn')" /> </textarea></br>
<input type="submit" id="idude" disabled value="Update Product Description" />
</form>
</div>
<div id="duim">
<form action=<?php echo 'updateproductimage.php?productid='.$product_id.'&'?> method="POST" enctype="multipart/form-data">
<input type="FILE" id="epim" name="pic" required placeholder="Enter Product Name" accept="image/*" value="Go" onchange="checkdisable('epim','iduim')" onkeyup="checkdisable('epim','iduim')"> </br>
<input type="submit" id="iduim" disabled value="Update Product Image" />
</form>
</div>
</section>
<div>
</body>
<?php
echo '<br>';
echo '<div class = "rempro" align="right"><i class="fas fa-trash"></i> <a href="delete_product.php?product_id='.$product_id.'">Remove </div>';
echo '<br>';
?>
</html>