I want to delete selected data from the database.Before deleting I will ask to user confirmation, if he agree only data will be deleted the database based on member_id.For this, I want value to included page (deleteUser.php). How to do this one?.I know passing variable from one page to another using form and via href.But,here I am not getting how to pass the variable.
Can anyone assist me?
And I will get member_id via while loop like $userdetails['member_id']; in the code,
By using like this I can do.But I want to do using above code only.
<a href="http://localhost/Performance/login/deleteUser.php?" class="delete" name="delete" data-toggle="modal"><i class="material-icons" data-toggle="tooltip" title="Delete" Onclick="return ConfirmDelete()"></i></a>
My code is,
<?php
include_once "deleteUser.php";
?>
<table class="table table-striped table-hover">
<thead>
<tr>
<th>
<span class="custom-checkbox">
<input type="checkbox" id="selectAll">
<label for="selectAll"></label>
</span>
</th>
<th>Username</th>
<th>Email</th>
<th>Role</th>
</tr>
</thead>
<tbody>
<?php
while($userdetails = mysqli_fetch_array($res, MYSQLI_ASSOC)){
echo' <tr>
<td>
<span class="custom-checkbox">
<input type="checkbox" id="checkbox1" name="options[]" value="1">
<label for="checkbox1"></label>
</span>
</td>
<td>'.$userdetails['username'].'</td>
<td>'.$userdetails['email'].'</td>
<td>'.$userdetails['role'].'</td>
<td>
<a href="#editEmployeeModal" class="edit" data-toggle="modal"><i class="material-icons" data-toggle="tooltip" title="Edit"></i></a>
<a href="#deleteEmployeeModal" class="delete" name="delete" data-toggle="modal"><i class="material-icons" data-toggle="tooltip" title="Delete"></i></a>
</td>
</tr>';
}?>
</tbody>
</table>
<div id="deleteEmployeeModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<form method="post" action="#" method="post" autocomplete="off">
<div class="modal-header">
<h4 class="modal-title">Delete Employee</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<p>Are you sure you want to delete these Records?</p>
<p class="text-warning"><small>This action cannot be undone.</small></p>
</div>
<div class="modal-footer">
<input type="button" class="btn btn-default" data-dismiss="modal" value="Cancel">
<input type="submit" class="btn btn-danger" name="deleteUser" value="Delete">
</div>
</form>
</div>
</div>
</div>
my deleteUser.php code,
include_once '../Connection/dbconnect.php';
if(isset($_POST['deleteUser'])){
//further codes will be here
}
Try this.
if(isset($_POST['deleteUser'])){
$member_id = $_POST['options'];
// write delete sql query here
}