1){ while($thumbnail=mysqli_fetch_assoc($thumbnails_result)){ $thumbnail_path="../images/" . $thumbnail['thumbnail']; if($thumbnail_path){ unlink($thumbnail_path); } } } // delete user from database $delete_user_query = "DELETE FROM users WHERE id = $id"; $delete_user_result = mysqli_query($connection, $delete_user_query); if(mysqli_errno($connection)){ $_SESSION['delete-user']="Couldn't delete '{$user['firstname']}' '{$user['lastname']}'"; } else{ $_SESSION['delete-user-success']="'{$user['firstname']} {$user['lastname']}' has been deleted successfully"; } } header("location: " . ROOT_URL . "admin/manage-users.php"); die();