07-15-2017, 03:53 PM
You can have your checkboxes do multiple things by keeping everything in one form. In your $_POST array, your submit button value will be whichever button was pressed.
Code:
<form name="testForm" action="test.php" method="post">Code:
<input type="checkbox" name="checkbox1" /> Checkbox 1<br />Code:
<input type="checkbox" name="checkbox2" /> Checkbox 2<br />Code:
<input type="checkbox" name="checkbox3" /> Checkbox 3Code:
<div class="text-center">Code:
<input type="hidden" name="csrf" value="<?= $token; ?>" />Code:
<input type="submit" name="testFormSubmit" value="Archive" class="btn btn-default" />Code:
<input type="submit" name="testFormSubmit" value="Delete" class="btn btn-default" />Code:
</div>Code:
</form>Code:
echo 'This is the POST data when the Archive button and some checkboxes are pressed:Code:
print_r($_POST);Code:
ArrayCode:
(Code:
[checkbox1] => onCode:
[checkbox3] => onCode:
[csrf] => 99f54e1d96a818733f1d3e98a1bc6101Code:
[testFormSubmit] => ArchiveCode:
)