I have the following Index:
<html>
<head>
<title>Productos</title>
</head>
<body>
<h2>Productos</h2>
<hr>
<form method="post" action="productos.php">
Elige tu producto:
<select name="listings">
<option value="Seleccionar">Seleccionar</option>
<option value="cocacola" <?php if($listings1 == "cocacola") print('selected="selected"'); ?> >Coca Cola</option>
<option value="fanta" <?php if($listings2 == "fanta") print('selected="selected"'); ?> >Fanta </option>
<option value="pepsi" <?php if($listings3 == "pepsi") print('selected="selected"'); ?> >Pepsi</option>
</select>
<br>
<br>
Unidades:
<br>
<input type="text" name="Unidades">
<br>
<input type="submit" name="Aceptar">
</form>
</body>
</html>
and the products.php file with the following source code:
<?php
$value=$_POST["listings"];
$listings1=$_POST['cocacola'];
$listings2=$_POST['fanta'];
$listings3=$_POST['pepsi'];
$precio_pepsi=25;
$precio_fanta=20;
$precio_coca=30;
switch ($listings) {
case
$listings3:
echo "Has pedido ".$_REQUEST['Unidades']." unidades de Pepsi Cola";
echo "<br>";
echo "Precio total: ". $precio_pepsi * $_REQUEST['Unidades'];
break;
case
$listings2:
echo "Has pedido ".$_REQUEST['Unidades']." unidades de Fanta Naranja";
echo "<br>";
echo "Precio total: ". $precio_fanta * $_REQUEST['Unidades'];
break;
case
$listings1:
echo "Has pedido ".$_REQUEST['Unidades']." unidades de Coca Cola";
echo "<br>";
echo "Precio total: ". $precio_coca * $_REQUEST['Unidades'];
break;
}
?>
the question is seleciono fanta but always the result I get coca cola why does this usually happen? as I see it seems that it does not take the variables it is appreciated help in advance.