I have a table included in a form, for the purpose of gathering the ID value of each row with a checkbox, and a button from outside the table to submit the form from outside of it.
Right now it works only for one function, submitting with a POST, but what if I wanted multiple functions?
I cannot include the buttons inside the form, because I have other functions to be placed inside it and would conflict breaking the form.
My code atm is:
<html>
<body>
<button type="submit" form="form">Submit</button>
<table>
<thead>
<tr><th>Value</th></tr>
<tr><th>Name</th></tr>
</thead>
<tbody>
<form action="page.php" method="POST" id="form">
<?php
foreach($datas as $d){
echo '<tr><td><input type="checkbox" name="array[] value='.$d["id"].' />'.$d["id"].'</td></tr>';
}
?>
</form>
</tbody>
</table>
This works fine if I only want to submit the values, but what if I want multiple buttons with multiple actions, something like this, from outside the form:
<html>
<body>
<button type="submit" form="form" name="submit">Submit</button>
<button type="submit" form="form" name="delete">Delete</button>
<button type="submit" form="form" name="export">Export</button>
...
And then gather them in page.php with:
if (isset($_POST['submit'])) //do submit actions
if (isset($_POST['delete'])) //do delete actions
if (isset($_POST['export'])) //do export actions
I've tried doing so, with no luck, so, how would you fix that? Is there any ways of accomplish this?