My Bootstrap 3 edit form had initially only a Submit button that worked perfectly. When I added another button to implement a 'Cancel' option, it didn't work as expected, and a click on it is submitting the form (and saving changes). Of course I didn't mark this second button as 'Submit', not being intended for that.
My HTML/PHP code looks like this:
<form method='POST' action='savechanges.php'>
<div class="form-group">
<label for="IdDataList">List Id</label>
<input type="text" class="form-control" id="IdDataList" readonly value="<?php echo $row['IdDataList']; ?>">
</div>
<div class="form-group">
<label for="DataListName">List Name</label>
<input type="text" class="form-control" id="DataListName" name="DataListName" value="<?php echo $row['DataListName']; ?>">
</div>
<div class="form-group">
<label for="DataListDescription">Description</label>
<input type="text" class="form-control" id="DataListDescription" name="DataListDescription" value="<?php echo $row['DataListDescription']; ?>">
</div>
<!-- Submit button -->
<div class="form-group col-sm">
<button class="btn btn-primary" name="saveall" type="submit" >Save changes</button>
</div>
<!-- Here the second 'Cancel' button -->
<div class="form-group col-sm">
<button class="btn btn-primary" name="goback" onclick="window.location.href='anotherpage.php'">Cancel</button>
</div>
</form>
Must be something obvious but I can't see what's going wrong... Thanks in advance!