So I am trying to make a shopping cart. What I need to do is send a product id and a quantity the user wants to buy to another file cart.php
.
Here is a section of my code:
for($i=0;$i<$numOfRows;$i++){
$prodID=mysql_result($result, $i, "ProductID");
$prodTitle=mysql_result($result, $i, "Title");
$prodAuthor=mysql_result($result, $i, "Author1");
$prodPrice=mysql_result($result, $i, "Price");
Print"<h4>ID: $prodID \n </h4>";
Print"<h4>Title: $prodTitle \n </h4>";
Print"<h4>Author: $prodAuthor \n </h4>";
Print"<h4>Price: $ $prodPrice \n </h4>";
Print" <form method ='POST'>";
Print"<p><label> Quantity";
Print"<input name='quantity' type='text' pattern='[1-9]{1,50}'/>";
Print"</label>";
Print"<input type='button' value='Add To Cart' onClick='cart.php?pid=$prodID'/>";
Print"</p></form>";
}
If I get rid of the form and just have <a href='cart.php?pid=$prodID'>Add To Cart</a>
it sends the id but I also need the quantity to go along with it.
Whenever I click Add To Cart it doesn’t send me to my cart.php
.