<?php include 'login.php';?>
<?php
session_start();
 if (!file_exists('users/'.$_SESSION['username']. '.xml')) {
    header('Location:index.php');
     die;
 
 
 }


?>
<html>
<?php include 'header.php';?>

    
    <div class="content">

            <div class="content2">
<!-- here the text-->                
                
        <h1>User Page</h1>
        <h2>Welcome, <?php echo $_SESSION['username'];?></h2>
        <table>
            <th>Username</th>
            <th>Email</th>

            <?php 
            $files = glob('users/*.xml');
            foreach ($files as $file) {
                $xml = new SimpleXMLElement($file, 0, true);
                echo '
                <tr>
                    <td>'. basename($file, '.xml') .'</td>
                    <td>'. $xml->email .'</td>
                <tr>';
            }
            
            ?>
        </table>
        <hr/>
        <a href="changepassword.php">Change Password</a>
        <a href="logout.php">Log out</a>
<!-- here the text-->             
        </div>

    </div>
    
<?php include 'sidebar.php';?>
    </div> 
    </body>
</html>