-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcart_backend.php
More file actions
104 lines (79 loc) · 2.22 KB
/
Copy pathcart_backend.php
File metadata and controls
104 lines (79 loc) · 2.22 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
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
<?php
if($_POST){
require 'b_db_key.php';
$conn = connect_db();
session_start();
if(isset($_POST['update']))
{
$email=$_SESSION['email'] ;
$sql = "SELECT * FROM buyer where email='$email'";
$result = $conn->query($sql);
$row = $result->fetch_assoc();
$uid = $row["uid"];
$pid=$_POST['pid'];
$quantity=$_POST['quantity'];
$sql="update cart set qty='$quantity' where pid='$pid' and uid='$uid'";
$sql=$conn->query($sql);
header('location: show_cart.php');
exit();
}
else if(isset($_POST['Dispatch']))
{
$email=$_SESSION['email'] ;
$sql = "SELECT * FROM buyer where email='$email'";
$result = $conn->query($sql);
$row = $result->fetch_assoc();
$uid = $row["uid"];
$str=$_POST['Dispatch'];
list($u_id,$p_id)=explode('.',$str);
$uid=(int)$u_id;
$pid=(int)$p_id;
$sql="update cart set stat=2 where uid='$uid' and pid='$pid' and stat=1";
$sql=$conn->query($sql);
header('location: s_pending_orders.php');
exit();
}
else if(isset($_POST['Completed']))
{
$email=$_SESSION['email'] ;
$sql = "SELECT * FROM buyer where email='$email'";
$result = $conn->query($sql);
$row = $result->fetch_assoc();
$uid = $row["uid"];
$str=$_POST['Completed'];
list($u_id,$p_id)=explode('.',$str);
$uid=(int)$u_id;
$pid=(int)$p_id;
$sql="update cart set stat=3 where uid='$uid' and pid='$pid' and stat=2";
$sql=$conn->query($sql);
header('location: s_pending_orders.php');
exit();
}
else if(isset($_POST['SUBMIT']))
{
$email=$_SESSION['email'] ;
$sql = "SELECT * FROM buyer where email='$email'";
$result = $conn->query($sql);
$row = $result->fetch_assoc();
$uid = $row["uid"];
$pid=$_POST['SUBMIT'];
$sql="delete from cart where pid='$pid' and uid='$uid'";
$sql=$conn->query($sql);
header('location: show_cart.php');
exit();
}
else if(isset($_POST['place_order']))
{
$email=$_SESSION['email'] ;
$sql = "SELECT * FROM buyer where email='$email'";
$result = $conn->query($sql);
$row = $result->fetch_assoc();
$uid = $row["uid"];
$sql="update cart set stat=1 where uid='$uid' and stat='0'";
$result = $conn->query($sql);
$sql="update cart set orderdate = getdate() where uid='$uid'";
$result = $conn->query($sql);
header('location: HOMEPAGE.php');
}
}
?>