-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckout.php
More file actions
36 lines (24 loc) · 918 Bytes
/
checkout.php
File metadata and controls
36 lines (24 loc) · 918 Bytes
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
<?php
session_start();
include './config.php';
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$unique_link = uniqid();
if (isset($_SESSION['cart']) && !empty($_SESSION['cart'])) {
foreach ($_SESSION['cart'] as $key => $value) {
$productName = $value['productName'];
$productPrice = $value['productPrice'];
$productPrice2 = $value['productPrice2'];
$productImage = $value['productImage'];
$sql = "INSERT INTO checkout_products (productName, productPrice, productPrice2, productImage, link)
VALUES ('$productName', '$productPrice', '$productPrice2', '$productImage', '$unique_link')";
if ($conn->query($sql) !== TRUE) {
echo "Error: " . $sql . "<br>" . $conn->error;
}
}
header("Location: checkout_success.php?link=$unique_link");
exit();
}
$conn->close();
?>