Add-cart.php Num [ TESTED • CHECKLIST ]
<form method="post" action="add-cart.php"> <input type="hidden" name="product_id" value="123"> <label>Quantity:</label> <input type="number" name="num" value="1" min="1" max="99"> <button type="submit">Add to Cart</button> </form>
Before processing any add-cart request, enforce: add-cart.php num
<?php session_start(); require 'db.php'; // assume DB connection and helper functions <form method="post" action="add-cart
He refreshed the database. The inventory for Item 9021 hadn't decreased. It had increased. form method="post" action="add-cart.php">
add-cart.php?id=100&num=-999
Instead, use a clear, explicit design:
// Fetch product from DB and check stock // ...