Ver Mensaje Individual
  #1 (permalink)  
Antiguo 07/01/2009, 07:25
raymel
 
Fecha de Ingreso: enero-2009
Mensajes: 1
Antigüedad: 15 años, 3 meses
Puntos: 0
Problema con un código

Hola a todos.
Estoy tratando de realizar un carrito de compras y e visto uno que me gusta en webestilo, ahora cuando lo ejecuto me da el siguiente error en el navegador.

Notice: Undefined index: item in c:\archivos de programa\easyphp1-8\www\index.php on line 4

Notice: Undefined index: cantidad in c:\archivos de programa\easyphp1-8\www\index.php on line 5

como podran ver uso el easyphp.
No se por que da ese error
el cñodigo es este.

<?php // Manual de PHP de WebEstilo.com
session_start();
session_register('itemsEnCesta');
$item=$_POST['item'];
$cantidad=$_POST['cantidad'];
$itemsEnCesta=$_SESSION['itemsEnCesta'];

if ($item){
if (!isset($itemsEnCesta)){
$itemsEnCesta[$item]=$cantidad;
}else{
foreach($itemsEnCesta as $k => $v){
if ($item==$k){
$itemsEnCesta[$k]+=$cantidad;
$encontrado=1;
}
}
if (!$encontrado) $itemsEnCesta[$item]=$cantidad;
}
}
$_SESSION['itemsEnCesta']=$itemsEnCesta;
?>
<html>
<body>
<tt>
<form action="<?=$PHP_SELF."?".$SID?>" method="post">
Dime el producto <input type="text" name="item" size="20"><br>
Cuantas unidades <input type="text" name="cantidad" size="20"><br>
<input type="submit" value="Añadir a la cesta"><br>
</form>
<?
if (isset($itemsEnCesta)){
echo'El contenido de la cesta de la compra es:<br>';
foreach($itemsEnCesta as $k => $v){
echo 'Artículo: '.$k.' ud: '.$v.'<br>';
}
}
?>
</tt>
</body>
</html>