Я хочу получить идентификатор продукта и количество на странице addToCart.php, когда пользователь нажимает кнопку «Добавить в корзину», когда текстовое поле генерируется динамически через цикл? Может ли кто-нибудь помочь мне, как получить количество и идентификатор продукта на другую страницу.
Вот код:
<?php
include('connection.php');
?>
<!DOCTYPE html>
<html>
<head>
<style>
</style>
</head>
<body>
<h1 align="center">Product Catlogs</h1>
<hr>
<?php
//Printing number of products in carts of user
$uid = $_SESSION['userId'];
$sql = "SELECT * FROM cart where cartUserId='$uid'";
$result = $conn->query($sql);
$dealcount=mysqli_num_rows($result);
?>
<p><a href="cart.php"><button id="goToCart">Go to Cart <span><?php echo $dealcount?><span></button></a></p>
<?php
$sql = "SELECT * FROM products";
$result = mysqli_query($conn, $sql);
while($row = $result->fetch_assoc())
{?>
<div class="card">
<img src="product_images/<?php echo $row['productImage']?>" height="230" style="width:100%">
<h1><?php echo $row['productName'] ?></h1>
<p class="price">RS-<?php echo $row['productPrice']?></p>
<p><?php echo $row['productDescription']?></p>
<form method="post" action="addTocart.php">
<p>Product Id:<input type="text" value="<?php echo $row['productId']?>" disabled></p>
<p>Quantity:<input type="number" placeholder="quantity" name=""></p>
<p><input type="submit" value="Add to cart" name="" onclick="alert('Product Added to your cart');"></p>
</form>
</div>
<?php
}
?>
</body>
</html>