-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinsert.php
36 lines (33 loc) · 1.17 KB
/
insert.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
<?php
$productName = $_GET['name'];
$productImage = $_GET['image'];
$productPrice = $_GET['price'];
$productID = $_GET['productid'];
$con = mysqli_connect("localhost","root","","dbsc");
$sql = "CALL SearchOrderCart('$productID')";
$result = mysqli_query($con, $sql);
$row = mysqli_fetch_array($result);
if($row !== null && $row['PRODUCT_ID'] == $productID) {
$conn = new mysqli("localhost","root","","dbsc");
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "CALL EditData('$productID')";
mysqli_query($conn, $sql);
$conn->close();
echo "<script>
window.location.href='cart.php';
</script>";
}else if($row == null) {
$conn = new mysqli("localhost","root","","dbsc");
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "CALL InsertData('$productID', '$productName', '$productPrice', '1', '$productImage')";
mysqli_query($conn, $sql);
$conn->close();
echo "<script>
window.location.href='cart.php';
</script>";
}
?>