Ver Mensaje Individual
  #1 (permalink)  
Antiguo 15/04/2002, 20:49
jandungo
 
Fecha de Ingreso: abril-2002
Mensajes: 2
Antigüedad: 22 años
Puntos: 0
Sesiones Php!!! Buuaaa No Resulta...:-(

Como hago un carro de compras porfavor.ni idea.......no funciona en win2000.....este codigo
no funcion el register....siempre entra a la condicion if (!isset($itemsEnCesta)).....
<?php
session_start();
session_register('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;
}
}
?>
<html>
<body>
<tt>
<form action="<?=$PHP_SELF."?".SID?&gt ;" 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>