<?php

require_once '../../classes/dbClass.php';
if (isset($_GET['id'])) {
    $id = $_GET['id'];
    if (dbClass::getUserById($id)) {
        if (dbClass::deleteUser($id)) {
            header('location: index.php');
        } else {
            header('location: index.php');
        }
    } else {
        header('location: index.php');
    }
} else {
    header('location: index.php');
}
    
    <a href='create.php' class='btn'>New folder permission</a>
    
    <table class='table' width='100%' cellpadding='5' cellspacing='0'>
        <tr>
            <th>ID</th>
            <th>Group</th>
            <th>Password</th>
            <th>Set up By</th>
            <th>Created</th>
            <th>&nbsp;</th>
        </tr>
        <?php 
$passwords = dbClass::fetchAllPasswords();
foreach ($passwords as $password) {
    $adminName = dbClass::getUserById($password['admin_id'])['username'];
    ?>
        <tr>
            <td><?php 
    echo $password['id'];
    ?>
</td>
            <td><?php 
    echo $password['name'];
    ?>
</td>
            <td><?php 
    echo $password['password'];
    ?>
</td>
            <td><?php 
<?php

require_once '../../classes/dbClass.php';
if (isset($_GET['id'])) {
    $id = $_GET['id'];
    $query = dbClass::getUserById($id);
    if ($query) {
        include '../header.php';
        require_once '../../classes/dbClass.php';
        require_once '../../helpers/security.php';
        ?>

<div class='panel'>
    <h2><?php 
        echo $query['username'];
        ?>
's profile</h2>
    
    <a href='index.php' class='btn'>View Users</a>
    &nbsp;&nbsp;&nbsp;
    <a href='edit.php?id=<?php 
        echo $id;
        ?>
' class='btn view'>Edit user</a>
    &nbsp;&nbsp;&nbsp;
    <a href='javascript:if(confirm("Are you sure?")){ window.location="delete.php?id=<?php 
        echo $id;
        ?>
"; }' class='btn delete'>Delete user</a>
    <br><br>