Uname : Linux V-ShopU01 4.18.0-348.20.1.el8_5.x86_64 #1 SMP Thu Mar 10 20:59:28 UTC 2022 x86_64
Server : Apache/2.4.37 (rocky) OpenSSL/1.1.1k
Whoami : apache
Safe Mode : OFF
DOCUMENT ROOT : /var/www/html/site_shopudietDisable Function :
Path : /var/www/html/site_shopudiet/
Server IP : 65.20.74.164
Client IP : 18.224.30.42
Current File : /var/www/html/site_shopudiet/update_cart.php |
<?php
include 'dbconnect.php';
session_start();
if(!isset($_SESSION['id'])){
header('Location: login_shop.php');
}
// logout
if(isset($_POST['but_logout'])){
session_destroy();
header('Location: login_shop.php');
}
$id=$_GET['id'];
$cart_id=$_SESSION['cart_id'];
$sql="select * from product where id='".$id."' ";
$result=mysqli_query($conn,$sql);
$row = mysqli_fetch_array($result);
$price=$row['price'];
$no_item=$_POST['qty'];
$total=$price*$no_item;
$sql="update product_cart set no_of_item='$no_item',total='$total' where id='$cart_id' ";
if(mysqli_query($conn,$sql)){
// echo '<script type="text/javascript">alert("Added to cart");window.location.assign("home.php");</script>';
header('location:shopping-cart.php');
}
else{
echo"not inserted".mysqli_error();
}
mysqli_close($conn);
?>