diğer sayfalara php kendini ve geçen bilgilerin nasıl kullanılacağı

0 Cevap php

I'm doing a little project that acts like a cart. When I click this link:

echo "<td><a href=\"$_SERVER[PHP_SELF]?action=zero&commitbuy.php?ids=$id&qoh=$qtyhand&qtb=$quantity\">ok</a></td>";

Ben tamam linki tıkladığınızda sepeti tablodan ürünü silmek, hangi programın eylemi sıfır gerçekleştirmek istiyorum:

<?php

    $product_id = $_GET['id'];   
    $action     = $_GET['action']; 


    if($product_id && !productExists($product_id)) {
        die("Error. Product Doesn't Exist");
    }

    switch($action) {   

        case "add":
            $_SESSION['cart'][$product_id]++; 
        break;

        case "remove":
            $_SESSION['cart'][$product_id]--; 
            if($_SESSION['cart'][$product_id] == 0) unset($_SESSION['cart'][$product_id]); 
        break;

        case "zero":
            $_SESSION['cart'][$product_id]==0;

        break;

        case "empty":
            unset($_SESSION['cart']); 
        break;

    }
?>

Then also, commitbuy.php would update the quantity of that certain product. What can you suggest that I would do with this. It doesn't seem to work. When I add this code:

$_SERVER[PHP_SELF]?action=zero

Bu birine:

 echo "<td><a href=\"commitbuy.php?ids=$id&qoh=$qtyhand&qtb=$quantity\">ok</a></td>";

0 Cevap