I have a shopping system. For example, the total AMOUNT bought must be 300, but the AMOUNT that inputs to the database is always 0.
here is the script code
function checkout(){
include('../db.php');
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$contact = $_POST['contact'];
$email = $_POST['email'];
$address = $_POST['address'];
$fullname = $fname.' '.$lname;
$date = date('m/d/y h:i:s A');
$item = '';
foreach($_SESSION['cart'] as $row):
if($row['qty'] != 0){
$product = '('.$row['qty'].') '.$row['product'];
$item = $product.', '.$item;
}
endforeach;
$amount = $_SESSION['totalprice'];
echo $q = "INSERT INTO dbgadget.order VALUES (NULL, '$fullname', '$contact', '$address', '$email', '$item', '$amount', 'unconfirmed', '$date', '')";
mysql_query($q);
unset($_SESSION['cart']);
header("location:../success.php");
}
the $amount variable date is not getting the correct value from the other page
this is the value of the $amount variable from the other page
<?php $_SESSION['totalprice'] = isset($_SESSION['totalprice']) ? $_SESSION['totalprice'] : $total; ?>