The following code is HTML for a form through Bootstrap 3. All the CSS and JS is stock. This snippet is part of a bigger form that is of method post and the action loops the page (that is to say the action is the same URL as the page itself).
<div class="form-group">
<div class="col-sm-12 text-center">
<label for="inputName" class="col-sm-5 control-label"><abbr title="Please select how you are paying today">How Are You Paying Today? (Optional)</abbr></label>
<div class="btn-group" role="group" aria-label="...">
<button type="button" class="btn btn-default" data-toggle="button" name="cash" id="cash" checked><span class="glyphicon glyphicon-usd"></span> Cash</button>
<button type="button" class="btn btn-default" data-toggle="button" name="card" id="card" checked><span class="glyphicon glyphicon-credit-card"></span> Card Of Some Sort</button>
<button type="button" class="btn btn-default" data-toggle="button" name="IOU" id="IOU" checked><span class="glyphicon glyphicon-info-sign"></span> IOU (Favor)</button>
<button type="button" class="btn btn-default" data-toggle="button" name="Other" id="Other" checked><span class="glyphicon glyphicon-question-sign"></span> Other</button>
</div>
</div>
</div>
...
This is a basic test method to see if cash is selected.
<?php
if(isset($_POST['cash']))
{
echo "cash selected";
}
?>
Nothing echoed. Eventually I want to have it where whichever button is selected gets passed to a PHP script to be stored in a database. But when the form is submitted, it looks like the button is selected, but it does not get submitted. Still pretty new to Bootstrap, so I'm learning all the CSS tricks and what not.
Any ideas why this information isn't passed to the PHP script?
EDIT: Updated some code at the advice of Fred. Here is the present HTML.
<div class="btn-group" role="group" aria-label="...">
<button type="submit" class="btn btn-default" data-toggle="button" name="cash[]" id="cash" checked><span class="glyphicon glyphicon-usd"></span> Cash</button>
<button type="submit" class="btn btn-default" data-toggle="button" name="card[]" id="card" checked><span class="glyphicon glyphicon-credit-card"></span> Card Of Some Sort</button>
<button type="submit" class="btn btn-default" data-toggle="button" name="IOU[]" id="IOU" checked><span class="glyphicon glyphicon-info-sign"></span> IOU (Favor)</button>
<button type="submit" class="btn btn-default" data-toggle="button" name="Other[]" id="Other" checked><span class="glyphicon glyphicon-question-sign"></span> Other</button>
</div>
<button type="button"will not work for POST method. Use<button type="submit" ... name="cash"...checkboxorselectname="cash[]"because you'll only get one value back and needs to be treated as an array. Or use a<select>as Waki said and use a submit button to process the whole thing. However, what I initially said, still does stand true about button types.