hi, im making an eCommerce store, i have have add to cart button working, the data for size and qty ads to the table, however, the model and product id do not. ive used the get method to get the product from the men page to the item page as shown here.
<?php
include 'mysql.php';
$show_men="SELECT DISTINCT model, id, price,image FROM products WHERE id='1' ";
$query_men=mysqli_query($conn,$show_men);
while($row=mysqli_fetch_array($query_men,MYSQLI_ASSOC)){
echo '<br><br><table class="table"><tbody>
<tr>
<div><center><img class="img-responsive" src="../images/'.$row['image'].'" width="400" height="300"></center><br>
<center><strong>'.$row['model'].'</strong><br><br><strong>Price:£ '.$row['price'].'</strong><br><br>
<a href="../php/item.php?id1='.$row['id'].'" class="btn btn-default">More Info</a><br><br><strong></center></div><hr>
</tr>
</tbody>
</table>';
}
?>
this is the part on the item page.
$custid = $_SESSION['custid'] ;
$price = $_POST['price'];
$productid=$_GET['id1'];
$size = $_POST['size'];
$qty = $_POST['qty'];
$model = mysqli_real_escape_string($conn, stripslashes($_POST['model']));
$now = date("Y-m-d H:i:s");
$sql = "INSERT INTO cart (custid, price, product_id, size, qty, model, created) VALUES ('" . $custid . "','" . $price . "', '" . $product_id . "', '" . $size . "', '" . $qty . "', '" . $model . "', '" . $now . "')";
$result = mysqli_query($conn, $sql);
if ($result == 1) {
$res = "Added to cart";
} else {
$res = "Error saving cart data";
}
}
?>
there is something i have missed, if anyone can spot it id be greatful. thanks