-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremoveOrAdd.php
98 lines (75 loc) · 2.47 KB
/
removeOrAdd.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
<?php
session_start();
require 'connectDB.php';
if(!(isset($_SESSION['email']))) {
header("Location: login.php");
exit();
}
else {
$pid = $_GET['pid'];
$action = $_GET['action'];
$table = $_GET['t'];
$finishTime = $_POST['finishTime'];
if ($table=='public') {
//SQL Query
$sql= "DELETE FROM `products` WHERE `products`.`productid` = $pid";
if(mysqli_query($conn,$sql)) {
$_SESSION['message']= "Product deleted Sucessfully!!";
header("Location: message.php");
exit();
} else {
$_SESSION['message']= mysqli_error($conn)."<br>Deletion error in table!!";
header("Location: message.php");
exit();
}
} else if ($table=='private') {
if ($action=='delete') {
//SQL Query
$sql= "DELETE FROM `privateproducts` WHERE `privateproducts`.`productid` = $pid";
if(mysqli_query($conn,$sql)) {
$_SESSION['message']= "Product deleted Sucessfully!!";
header("Location: message.php");
exit();
} else {
$_SESSION['message']= mysqli_error($conn)."<br>Deletion error in table!!";
header("Location: message.php");
exit();
}
}
else if ($action=='add') {
//SQL Query
$sql1 = "SELECT * FROM privateproducts WHERE productid=$pid";
$sql2= "DELETE FROM `privateproducts` WHERE `privateproducts`.`productid` = $pid";
$result = mysqli_query($conn,$sql1);
if(mysqli_num_rows($result)>0) {
$ans1 = mysqli_fetch_assoc($result);
$sql3= "INSERT INTO products(userid, product_name, price, bid_inc, image, finishtime, product_cat, description) VALUES ('".$ans1['userid']."','".$ans1['product_name']."','".$ans1['price']."','".$ans1['bid_inc']."','".$ans1['image']."','$finishTime','".$ans1['product_cat']."','".$ans1['description']."')";
if (mysqli_query($conn,$sql2) && mysqli_query($conn,$sql3)) {
$_SESSION['message']= "Product Added for Bidding Sucessfully!!";
header("Location: message.php");
exit();
}
else {
$_SESSION['message']= mysqli_error($conn)."<br>Table modification error!!";
header("Location: message.php");
exit();
}
} else {
$_SESSION['message']= "Something went wrong!";
header("Location: message.php");
exit();
}
}
else {
$_SESSION['message']= "Something went wrong!";
header("Location: message.php");
exit();
}
}
else {
$_SESSION['message']= "Something went wrong!";
header("Location: message.php");
exit();
}
}
?>