Hello guys I am having a problem with my code. I have a simple ecommerce site and I built this with no framework. The site is runnning without errors in my local PC. But when I moved this in the other PC.
This is the process of my wishlist. After submitting the form it will redirect to itself. The process is simply removing the item to the cart.
//remove item from cart
if(isset($_GET['remove_id'])) {
if(isset($_SESSION['member'])) {
fn_delete_item($_GET['remove_id'], $_SESSION['member']);
} else {
foreach ($_SESSION['cart'] as $key => $subarray){
if ($subarray['product_id'] == $_GET['remove_id']){
unset($_SESSION['cart'][$key]);
break;
}
}
}
header('Location: ?page=yoga_product&product='.$_GET['remove_id'].'&product_id='.$_GET['remove_id']);
}
//remove all items from cart
if(isset($_GET['removeall'])){
if(isset($_SESSION['member'])) {
fn_delete_all_item($_SESSION['member']);
unset($_SESSION['cart']);
} else {
unset($_SESSION['cart']);
}
header('Location: ?page=yoga_product&product='.$_GET['removeall'].'&product_id='.$_GET['removeall']);
}
......
echo "<div style='overflow-y: scroll; height:200px;'>";
echo "<table border='0' style='font-size: 12px; width: 100%' cellpadding='5'>";
echo "<tr>";
echo "<td style='background-color: white; color: black; text-align: center'>Product ID</td>";
echo "<td style='background-color: white; color: black; text-align: center'>Name</td>";
//echo "<td style='background-color: white; color: black; text-align: center'>Price</td>";
echo "<td style='background-color: white; color: black; text-align: center'>Sale Price</td>";
echo "<td style='background-color: white; color: black; text-align: center'>Quantity</td>";
echo "<td style='background-color: white; color: black; text-align: center'>Total</td>";
echo "<td style='background-color: white; color: black; text-align: center'><a href='?page=yoga_product&product=".$_GET['product_id']."&removeall=".$_GET['product_id']."' class='hover'>Remove All</a></td>";
echo "</tr>";
$total = 0;
if(isset($_SESSION['member'])) {
$cart_data = fn_get_cart($_SESSION['member']);
$total_cart = fn_count_cart($_SESSION['member']);
while ($row = mysql_fetch_assoc($cart_data, MYSQL_ASSOC) ){
$link = '?page=yoga_product&product='.$row['product_id'].'&product_id='.$row['product_id'];
$update = '?page=yoga_product&product='.$row['product_id'].'&update_id='.$row['product_id'];
$remove = '?page=yoga_product&product='.$row['product_id'].'&remove_id='.$row['product_id']; //this will be the generated URL for removing.
$compute_total = $row['qty'] * $row['sale_price'];
echo "<tr>";
echo "<td style='text-align: center; background-color: gray; color: black'>".$row['product_id']."</td>";
echo "<td style='text-align: left; background-color: gray; color: black'><a href='$link' style='color: blue; '>".$row['product_name']."</a></td>";
//echo "<td style='text-align: right; background-color: gray; color: black; font-family: courier'>".number_format($row['price'],2)."</td>";
echo "<td style='text-align: right; background-color: gray; color: black; font-family: courier'>".number_format($row['sale_price'],2)."</td>";
echo "<td style='text-align: center; background-color: gray; color: black'>".$row['qty']."</td>";
echo "<td style='text-align: right; background-color: gray; color: black; font-family: courier'>".number_format($compute_total,2)."</td>";
echo "<td style='text-align: center; background-color: gray; color: black'>
<a href='$remove' class='hover'>Remove this?</a>
</td>";
echo "</tr>";
$total += ($row['sale_price'] * $row['qty']);
}
echo "</table>";
echo "</div>";
echo "<br />";
echo "<div align='right'>";
echo "<label>Total Items: ".$total_cart."</label> ";
echo "<label>Subtotal Amount: </label><input type='text' name='subtotal' value='".number_format($total,2)."' readonly='readonly' style='text-align: right; font-family: courier'>";
echo "<input type='submit' value='Place Item' disabled='disabled' />";
echo "</div>";
}
it will remove the item but I got an error.
Warning: Cannot modify header information - headers already sent by (output started at E:\xampp\htdocs\ahm\pages\main\menu.php:50) in E:\xampp\htdocs\ahm\pages\yoga\clothing_shop.php on line 179
I don't know how I got this error. In my local there's error like this. But when I moved this in other PC. I got this. I am accessing my page in this way. 10.x.x.x./ahm
Please help me guys. Thanks.