Initial Commit
This commit is contained in:
62
indexes/user/process/modify/item_add.php
Normal file
62
indexes/user/process/modify/item_add.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
include "../../../ConnectDB.php";
|
||||
|
||||
session_start();
|
||||
$uid = mysqli_real_escape_string($conn, $_SESSION['uid']);
|
||||
|
||||
if (isset($_GET["booking_id"]) && isset($_GET["table"])) {
|
||||
$booking_id = $_GET["booking_id"];
|
||||
|
||||
switch ($_GET["table"]) {
|
||||
case '1':
|
||||
$table = "hotel_booking";
|
||||
break;
|
||||
case '2':
|
||||
$table = "restaurant_booking";
|
||||
break;
|
||||
case '3':
|
||||
$table = "attraction_booking";
|
||||
break;
|
||||
case '4':
|
||||
$table = "guide_booking";
|
||||
break;
|
||||
case '5':
|
||||
$table = "transport_flight_booking";
|
||||
break;
|
||||
case '6':
|
||||
$table = "transport_railway_booking";
|
||||
break;
|
||||
default:
|
||||
echo "Unknown booking type";
|
||||
}
|
||||
|
||||
$price_query = "SELECT `subtotal_price` FROM cart_bookings WHERE booking_id=" . $booking_id;
|
||||
$priceRes = mysqli_query($conn, $price_query);
|
||||
$price = mysqli_fetch_assoc($priceRes);
|
||||
$price = $price["subtotal_price"];
|
||||
|
||||
$quantity_query = "SELECT quantity FROM `$table` WHERE booking_id='$booking_id'";
|
||||
$res = mysqli_query($conn, $quantity_query);
|
||||
$quantity = mysqli_fetch_assoc($res);
|
||||
$quantity = $quantity['quantity'];
|
||||
|
||||
$add = "UPDATE `$table` SET quantity = '$quantity' + 1 WHERE booking_id='$booking_id'";
|
||||
$res = mysqli_query($conn, $add);
|
||||
if (!$res) {
|
||||
echo "<script type='text/javascript'>
|
||||
alert('Error occurred!');
|
||||
</script>";
|
||||
}
|
||||
|
||||
$total = "UPDATE user_buyer SET cart_total_price = cart_total_price + '$price' WHERE u_id='$uid'";
|
||||
$res = mysqli_query($conn, $total);
|
||||
if (!$res) {
|
||||
echo "<script type='text/javascript'>
|
||||
alert('Error occurred!');
|
||||
</script>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
header('Location: ../cart.php');
|
||||
?>
|
||||
Reference in New Issue
Block a user