Sesiones : Carrito de Ventas

C) UN CARRITO DE VENTAS: LO QUE TANTO ESPERABAS: ALGO BÁSICO

Aquí aremos uso de la función isset aprendida anteriormente.

Ingresarproducto.php

<html>
<head>
</head>
<body>

<?php
SESSION_START();
if(isset($_REQUEST['ingresar']))
{
$clave=$_REQUEST['nombre'];
$_SESSION[$clave]=$_REQUEST['precio'];
}

?>

<form method="post" action="Ingresarproducto.php">
Nombre:<input type="text" name="nombre"><br>
Precio : <input type="text" name="precio"><br>
<input type="submit" name="ingresar" value="Ingresar">
</form>

<?php
echo "<table border='1'><tr><td>Producto</td><td>Precio</td></tr>";
foreach($_SESSION as $clave=> $valor)
{
echo "<tr><td>$clave</td><td>$valor</td></tr>";
}
?>
</body>
</html>

Descargar Ejemplo


No hay comentarios:

Publicar un comentario