I need to send to the addToCart.php page the variable $ idProductoColorTalla (of the element that is selected in the radiobutton) and the field unidades. I've already thought about it and I don't know how to get it. The variable $ idProductoColorTalla is the one that is together with the selected radiobutton.
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="jquery-latest.js"></script>
</head>
<body>
<?php
require("conexion.php");
$idProducto=$_POST["idProducto"];
$datos=mysqli_query($db,"select * from productos where id='$idProducto'");
$fila =mysqli_fetch_array($datos);
$nombreProducto=$fila["nombre"];
$datos=mysqli_query($db,"select * from productos where nombre='$nombreProducto' and mostrar=true");
$fila =mysqli_fetch_array($datos);
$datos2=mysqli_query($db,"select * from productos where nombre='$nombreProducto'");
echo("<image src='".$fila["imagen"]."'>");
echo($fila["nombre"]);
foreach($datos2 as $fila2)
{
echo("<form class='myForm' action='addToCart.php' method='post'>");
$idProductoColorTalla=$fila2["id"];
echo("<input type='radio' name='color' value='".$fila2["color"]."'>".$fila2["color"]."<br>");
//echo($fila2["talla"]."<br>");
echo("<input type='hidden' name='idProducto' value='".$idProductoColorTalla."'>");
echo("</form>");
}
echo("<form id='myForm' action='addToCart.php' method='post'>");
echo("<input type='number' id='unidades' name='unidades' value='1'>"."<br>");
echo($fila["precio"]);
echo("<input type='submit' id='anadirCarrito' name='anadirCarrito' value='A?adir al carrito'/>");
echo("</form>");
?>
</body>
</html>
question from:
https://stackoverflow.com/questions/65849028/how-to-send-variables-from-two-different-forms 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…