i've been trying submit 2 buttons, 1 delete , 1 edit/add. can't seem right.
html:
<!-- edit/delete account form --> <form method="get" action="edit.php" onsubmit="settimeout('location.reload()');"> <div id="edit-form" class="modal hide fade"> <div class="modal-header"> <a class="close" data-dismiss="modal">×</a> <h4><?php _e('edit/delete account'); ?></h4> </div> <div class="modal-body"> <div id="message"></div> <div class="control"> <div id="edit-account-form"> <table id="add-account" class="table"> <tbody> <tr> <td valign="middle"> account number </td> <td> <input type="hidden" id="editid" name="editid" value=""/> <input type="text" id="number" name="number" value="enter text here "/> </td> </tr> <tr> <td> account description </td> <td> <input type="text" id="description" name="description" value="enter text here "/> </td> </tr> <tr> <td> level 01 </td> <td> <input type="text" id="level01" name="level01" value="enter text here "/> </td> </tr> <tr> <td> level 02 </td> <td> <input type="text" id="level02" name="level02" value="enter text here "/> </td> </tr> <tr> <td> level 03 </td> <td> <input type="text" id="level03" name="level03" value="enter text here "/> </td> </tr> <tr> <td> level 04 </td> <td> <input type="text" id="level04" name="level04" value="enter text here "/> </td> </tr> <tr> <td> tax </td> <td> <input type="text" name="account" value="enter text here "/> </td> </tr> <tr> <td> allow general journals </td> <td> <select> <option selected disabled>select</option> <option>yes</option> <option>no</option> </select> </td> </tr> <tr> <td> allow payments </td> <td> <select>select</select> </td> </tr> <tr> <td> allow expense claims </td> <td> <select>select</select> </td> </tr> <tr> <td> show on dashboard </td> <td> <select>select</select> </td> </tr> </tbody> </table> </div> </div> </div> <div class="modal-footer"> <button type="submit" data-complete-text="<?php _e('done'); ?>" name="add" class="btn btn-primary pull-right"><?php _e('submit'); ?></button> <p class="pull-left"><button type="submit" name="delete" class="btn btn-primary pull-right"><?php _e('delete'); ?></button></p> </div> </div> </form>
php:
<?php //account details $number = $_get['number']; $description = $_get['description']; $level01 = $_get['level01']; $level02 = $_get['level02']; $level03 = $_get['level03']; $level04 = $_get['level04']; $id = $_get['editid']; $dbc = mysqli_connect('localhost', 'root', 'root', 'accounting') or die('connection error!'); if(isset($_post['delete'])) { $check = "delete accountslave `id` = '$id' "; mysqli_query($dbc, $check) or die('database error, delete account!'); } if(isset($_post['add'])) { //$check = "delete accountslave `id` = '$id' "; $check = "update accountslave set `accountnumber` = '$number', `accountdescription` = '$description', `accountlevel1` = '$level01', `accountlevel2` = '$level02', `accountlevel3` = '$level03', `accountlevel4` = '$level04' `id` = '$id'"; mysqli_query($dbc, $check) or die('database error, add account!'); } header('location:master-accounts.php'); ?>
it works when have 1 query. i've tried 1 query add , delete , worked. need submit delete if delete button clicked , vice versa.
i followed post try right multiple buttons on form
any or suggestions appreciated!
you need use $_get
instead of $_post
. should like
if(isset($_get['delete'])) {
and
if(isset($_get['add'])) {
because form submit method get
not post
Comments
Post a Comment