<meta charset="utf-8">
<link href="../../css/templatemo_style.css" rel="stylesheet" type="text/css" />
<?php
session_start();



if ($_SESSION['GROUPOFUSE'] == 0) {
    $pagetitle = "Διαχειριστή!!";
    include('../../divs/header.php');
} else {
    require_once('../../login/login_functions.inc.php');
    $url = absolute_url('../../login/login.php');
    header("Location: $url");
    exit();
}
?>


<!--  MENU  -->

<div id="templatemo_menu_wrapper">

    <div id="templatemo_menu">
        <ul>
            <li><a href="loggedin0.php" class="current"><span></span>Αρχική</a></li>
         
             
                <li><a href="eggrafi_user.php" target="_parent" ><span></span>Εγγραφή νέου Χρήστη</a></li>
                <li><a href="view_users.php" target="_parent" ><span></span>Εμφάνιση-Επεξεργασία Χρηστών</a></li>
            
            <li><a href="logout.php" target="_parent"><span></span>Logout </a></li>
        </ul>    
        
	</div>
        </ul>    
        
	</div>
    
    

</div>
</div> <!-- end of templatemo_menu -->

<div id="templatemo_main"> <span class="tm_bottom"></span>


    <!-- CONTENT -->
<?php

if ((isset($_GET['id'])) ) {
    $id = $_GET['id'];
   } elseif ((isset($_POST['id'])) ) {
    $id = $_POST['id'];
} else {
    echo '<p class="error">This page has been accessed in error.</p>';
    include('../../divs/footer.php');
    exit();
}
require_once('../../login/mysqli_connect.php');

if (isset($_POST['submitted'])) {
    if ($_POST['sure'] == 'Yes') {
        $q = "DELETE FROM users WHERE Username = '$id' LIMIT 1";
        $r = mysqli_query($dbc, $q);
        if (mysqli_affected_rows($dbc) == 1) {
            echo '<p>The user has been deleted from users.</p>';
        } else {
            echo '<h1>System Error</h1>
                <p class="error">The user could not be deleted
                due to a system error. We apologize for any inconvenience.</p>';
            echo '<p>' . mysqli_error($dbc) . '<br>Query: ' . $q . '</p>';
        }
                    
        
    } else {
        echo '<p>The user has <b>NOT</b> been deleted.</p>';
    }
} else {
    $q = "SELECT CONCAT(Username, ', ', Groupofuse) as name
        FROM users
        WHERE Username='$id'";
    $r = mysqli_query($dbc, $q);
    if (mysqli_num_rows($r) == 1) {
        $row = mysqli_fetch_array($r, MYSQLI_ASSOC);
        echo '
<form action="diagrafi_user.php" method="post"><br></br>
    <h3>Name:' . $row['name'] . '</h3>
    <p>Are you sure you want to delete this user?<br>
        <input type="radio" name="sure" value="Yes">Yes
        <input type="radio" name="sure" value="No" checked="checked">No</p>
    <p><input type="submit" name="submit" value="Submit"></p>
    <input type="hidden" name="submitted" value="TRUE">
    <input type="hidden" name="id" value="' . $id . '">
</form>';
    } else {
        echo '<h1>System Error</h1>
              <p class="error">We apologize for any inconvenience.</p>';
        echo '<p>' . mysqli_error($dbc) . '<br>Query: ' . $q . '</p>';
    }
}

mysqli_close($dbc);

?>

   
    
    
    
    
    
    

    <!-- SIDEBAR -->



    <div class="cleaner"></div>
</div> 




<?php
include('../../divs/footer.php');
?>