-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdateProd.php
More file actions
70 lines (54 loc) · 1.85 KB
/
updateProd.php
File metadata and controls
70 lines (54 loc) · 1.85 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
<?php
session_start();
$_SESSION["username"] = "";
$isAdmin = $_SESSION["isAdmin"];
$id = $_COOKIE['id'];
if ($isAdmin == 0){
header("Refresh:0; url=index.php");
exit;
}
require "Query.php";
Query::connectDatabase();
$pid = $_POST['pid'];
$product = $_POST['pname'];
$description = $_POST['description'];
$distInfo = $_POST['dist_info'];
$warrant = $_POST['warranty_status'];
$model = $_POST['model_number'];
$price = $_POST['price'];
$discPercentage = $_POST['discount'];
$stock = $_POST['stock_quantity'];
if($product != ""){
$query = "UPDATE PRODUCTS SET pname='$product' WHERE pid = '$pid'";
$result = Query::$conn->query($query);
}
if($description != ""){
$query = "UPDATE PRODUCTS SET description='$description' WHERE pid = '$pid'";
$result = Query::$conn->query($query);
}
if($distInfo != ""){
$query = "UPDATE PRODUCTS SET dist_info='$distInfo' WHERE pid = '$pid'";
$result = Query::$conn->query($query);
}
if($warrant != ""){
$query = "UPDATE PRODUCTS SET warranty_status='$warrant' WHERE pid = '$pid'";
$result = Query::$conn->query($query);
}
if($model != ""){
$query = "UPDATE PRODUCTS SET model_number='$model' WHERE pid = '$pid'";
$result = Query::$conn->query($query);
}
if($price != ""){
$query = "UPDATE PRODUCTS SET price='$price' WHERE pid = '$pid'";
$result = Query::$conn->query($query);
}
if($discPercentage != ""){
$query = "UPDATE PRODUCTS SET discount='$discPercentage' WHERE pid = '$pid'";
$result = Query::$conn->query($query);
}
if($stock != ""){
$query = "UPDATE PRODUCTS SET stock_quantity='$stock' WHERE pid = '$pid'";
$result = Query::$conn->query($query);
}
header("Refresh:0; url=listProds.php");
?>