I have been spinning my wheels trying to figure out why my php code is not able to reference a select box in my forms html. Here is the HTML form:
<form action="/cart.php" method="post">
<input type="hidden" name="action" value="add" />
<input type="hidden" name="sku" value="C3" />
<h3>Callaway</h3>
<div class="img-box">
<p>
<img alt="X Hot Pro Hybrid" src="/products/kona.jpg" />
<h7>X Hot Pro Hybrid</h7>
<br />
<label><strong>Price:</strong> 7.99
<br />
<strong>Availability:</strong> In Stock
<br />
<strong>Hand: </strong>
<select name="hand">
<option value="Right">Right</option>
<option value="Left">Left</option>
</select>
</label>
<br />
</p>
<p>
<a href="/cart.php?sku=C3&action=add" class="button">Add to Cart</a>
</p>
</div>
</form>
and here is the line from cart.php:
$hand = $_POST["hand"];
any thoughts?
It doesn’t look the form is actually posting. The Add to Cart button is just passing some parameters on the URL. You’ll have to add the value to the URL (via JavaScript) that the Add to Cart link is using (probably not a good idea), use an actual submit button or submit image or have the link submit the form using Javascript.