-
Notifications
You must be signed in to change notification settings - Fork 0
/
shoppingcart.php
66 lines (27 loc) · 1.74 KB
/
shoppingcart.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
<?php
//print_r($_SESSION);
$userid = $phoneid = $phonename = $phonebrand = $phonestorage = $phonecolor = $phoneimage = '';
if(isset($_POST['add'])){
if(!$_SESSION['email']) {
echo "Login to add item to cart";
} else {
$phonebrand = filter_input(INPUT_POST, 'brand', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$phonestorage = filter_input(INPUT_POST, 'storage', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$phonename = filter_input(INPUT_POST, 'phonename', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$phoneimage = filter_input(INPUT_POST, 'phoneimage', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
// $phoneimage = $_POST['phoneimage'];
$phonecolor = filter_input(INPUT_POST, 'color', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
// $sessionidentity = filter_input(INPUT_POST, 'sessionid', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$phoneid = filter_input(INPUT_POST, 'phoneid', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$userid = filter_input(INPUT_POST, 'userid', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$transactionid = filter_input(INPUT_POST, 'transid', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$quantity = $_POST['quantity'];
// $addcart = "INSERT INTO cart(userid, phoneid, PhoneName, Brand, Storage, Color, image) VALUES (`$userid`,`$phoneid`,`$phonename`,`$phonebrand`,`$phonestorage`,`$phonecolor`,`$phoneimage`)";
$addcart = "INSERT INTO cart (userid, phoneid, PhoneName, Brand, Storage, Color, image, quantity) VALUES (?,?,?,?,?,?,?,?)";
$stmt= $conn->prepare($addcart);
$stmt->bind_param("sssssssi", $userid, $phoneid, $phonename, $phonebrand, $phonestorage, $phonecolor, $phoneimage, $quantity);
$stmt->execute();
echo "Item added to cart to view cart ".'<a href="/cart.php">Go to Cart</a>';
}
}
?>