Tec. Ingenieria en Sistemas Informaticos
Publicado por Carlos Franco (2 intervenciones) el 20/03/2017 19:04:35
ME PUEDEN AYUDAR A ENCONTRAR LOS ERRORES DE ESTE CODIGO POR FAVOR...
SALUDOS, MUCHAS GRACIAS DE ANTE MANO
SALUDOS, MUCHAS GRACIAS DE ANTE MANO
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
session_start();
?>
<html>
<head>
<title>Carrito de Compras </title>
<meta charset="utf-8">
</head>
<body>
<form action="#" method="POST"> <br>
Producto:<input type="text" name="txtproduc"> <br>
Cantidad:<input type="text" name="txtcantidad"><br>
Precio:<input type="text" name="txtprecio"> <br>
<input type="submit" name="btnregistrar" value="registrar"> <br>
<input type="submit" name="btnMostrar" value="mostrar"> <br>
<input type="submit" name="btnReiniciar" value="Reiniciar"> <br>
<input type="submit" name="btnCalcular" vaciar="Calcular"> <br>
</form>
<?php
if(isset($_REQUEST["btnregistrar"]))
{
$Producto=$_REQUEST["txtproduc"];
$cantidad=$_REQUEST["txtcantidad"];
$precio=$_REQUEST["txtprecio"];
$total=0;
$_SESSION["carrito"][$producto]["cantidad"]=$cantidad;
$_SESSION["carrito"][$producto]["precio"]=$precio;
}
if(isset($_REQUEST["btnMostrar"]))
{
foreach ($_SESSION["carrito"] as $indice =>$arreglo)
{
print "Del producto: ".$indice."<br>";
foreach ($arreglo as $key => $value)
{
print($key ." = ". $value . "<br>");
}
}
}
if (isset($_REQUEST["btnCalcular"]))
{
foreach ($_REQUEST["carrito"] as $indice => $arreglo)
{
$total = $total + ($arreglo["cantidad"] * $arreglo["precio"]);
}
}
print "El total a pagar es $ ".$total;
if(isset($_REQUEST["btnReiniciar"]))
{
session_destroy();
}
?>
</body>
</html>
Valora esta pregunta
0