cannot retrieve value from $_POST
<p>$_POST[$key] does not return a value in my code.var_dump($_POST) gives the correct result.
When i try  echo $_POST[$key], it does not print anything. I'm using mamp; I read the previous post about the similar problem but no solution. Here is my code...
`

<pre><code>session_start();    

if(isset($_POST["submit"])){
    foreach($_SESSION["cart"] as $key =&gt; $qty){         
        if($_POST[$key] == '0'){
            unset($_SESSION["cart"][$key]);
        }
        else            
            $_SESSION["cart"][$key] = $_POST[$key];
        echo $_POST[$key];  
    }
    var_dump($_POST);
}

$cart = $_SESSION["cart"];
</code></pre>

<p>?></p>



<pre><code>    &lt;table border="1" cellpadding="10"&gt;
    &lt;form action="&lt;? echo $_SERVER["PHP_SELF"];?&gt;" method="post"&gt;
    &lt;?  
        if($cart)
        {
    ?&gt;
            &lt;th&gt;Item&lt;/th&gt;&lt;th&gt;Size&lt;/th&gt;&lt;th&gt;Quantity&lt;/th&gt;&lt;th&gt;Unit Price&lt;/th&gt;&lt;th&gt;Item Subtotal&lt;/th&gt;
    &lt;?
            $keys = array_keys($cart);

            foreach($keys as $key) 
            { 
                echo $key;
                $array = explode(".", $key);
                $name = $array[0];
                $size = $array[1];

                $quantity = $cart["$key"];
                echo $quantity;
                $price = $xml-&gt;xpath("//item[@name='$name']/price[@size='$size']");
                $unitPrice = (float) $price[0];

                $itemSubtotal = $unitPrice * $quantity;

                $total = $total + $itemSubtotal;
    ?&gt;
                &lt;tr&gt;
                    &lt;td&gt;&lt;? print($name); ?&gt;&lt;/td&gt;
                    &lt;td&gt;&lt;? print($size); ?&gt;&lt;/td&gt;
                    &lt;?  ?&gt;
                    &lt;td align="right"&gt;&lt;input type = "text" name="&lt;?print($key)?&gt;" value="&lt;? print($quantity); ?&gt;" size="3"/&gt;&lt;/td&gt;
                    &lt;td align="right"&gt;$&lt;? printf("%0.2f", $unitPrice); ?&gt;&lt;/td&gt;
                    &lt;td align="right"&gt;$&lt;? printf("%0.2f", $itemSubtotal); ?&gt;&lt;/td&gt;
                &lt;/tr&gt;
    &lt;?      
            }
    ?&gt;
            &lt;tr&gt;&lt;td colspan="5" align="right"&gt;&lt;b&gt;Total: $&lt;? printf("%0.2f", $total); ?&gt;&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
    &lt;?
        }
        else
        {
    ?&gt;
            Your cart is empty!
    &lt;?  }  ?&gt;

    &lt;input type="submit" name="submit" value="update" /&gt;
&lt;/form&gt;
    &lt;/table&gt;

    &lt;p&gt;&lt;a href="checkout.php"&gt;Checkout&lt;/a&gt;&lt;/p&gt;
</code></pre>

<p>`                                                                           </p>

<p>Can anyone please tell me what is wrong with my code? thanks in advance.</p>
