D7net Mini Sh3LL v1
Current File : C:/Domains/maymaytinson.com/httpdocs/lib/images/13/../10/../7/../16/../activity/../JUKI/../15/../zip_food/../18/../17/../2/../21/../20/../22/../5/../11/../7/../5/../22/../22/../../../upload/../upload/../conn/../include/cart.php |
<?php
if(isset($_SESSION['user'])){
$price=$_POST['priceProduct'];
$customer=$_SESSION['id'];
$check=$conn->prepare("SELECT * FROM cart WHERE customer='".$customer."'");
$check->execute();
$checks=$check->fetchAll(PDO::FETCH_ASSOC);
$flag=0;
foreach ($checks as $checks) {
if($_POST['idProduct']==$checks['product']){
$flag=1;
$ID=$checks['id'];
$AMOUNT=$checks['amount'];
}
}
$newAmount=$AMOUNT+$_POST['amountProduct'];
if($flag==0){
$stmt=$conn->prepare("INSERT INTO cart(customer,product,amount,price) VALUES(:customer,:product,:amount,:price)");
$stmt->bindParam(":customer",$customer,PDO::PARAM_INT);
$stmt->bindParam(":product",$_POST['idProduct'],PDO::PARAM_INT);
$stmt->bindParam(":amount",$_POST['amountProduct'],PDO::PARAM_INT);
$stmt->bindParam(":price",$price,PDO::PARAM_INT);
$stmt->execute();
}if($flag==1){
$stmt=$conn->prepare("UPDATE cart SET amount=:amount WHERE id='".$ID."'");
$stmt->bindParam(":amount",$newAmount,PDO::PARAM_INT);
$stmt->execute();
}
header("location:".$_SESSION['url']);
}else{
header("location:index.php");
}
?>
AnonSec - 2021 | Recode By D7net