Geizkragen/account.php

80 lines
1.7 KiB
PHP

<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
session_start();
if (empty($_SESSION['user_id']))
{
header('Location: login.php');
exit();
}
$userId = (int)$_SESSION['user_id'];
$servername = "localhost";
$port = 3306;
$username = "FSST";
$password = "L9wUNZZ9Qkbt";
$db = "FSST";
$conn = mysqli_connect($servername, $username, $password, $db, $port);
if (!$conn)
{
http_response_code(500);
die("Datenbankfehler");
}
$stmt = mysqli_prepare($conn, "SELECT userID, displayName, email FROM users WHERE userID = ? LIMIT 1");
if (!$stmt)
{
http_response_code(500);
die("Datenbankfehler");
}
mysqli_stmt_bind_param($stmt, "i", $userId);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
if ($result)
{
$user = mysqli_fetch_assoc($result);
}
else
{
$user = null;
}
mysqli_stmt_close($stmt);
mysqli_close($conn);
if (!$user)
{
session_unset();
session_destroy();
header('Location: login.php');
exit();
}
include 'header.php';
?>
<link rel="stylesheet" href="assets/css/login.css">
<main class="auth" role="main">
<section class="auth__grid" aria-label="Account Bereich">
<div class="auth__card">
<header class="auth__header">
<p class="auth__title">
Username: <?php echo htmlspecialchars($user['displayName'], ENT_QUOTES, 'UTF-8'); ?></p> <br>
<p class="auth__title">UserID: <?php echo (int)$user['userID']; ?></p> <br>
<p class="auth__title">Email: <?php echo htmlspecialchars($user['email']); ?></p>
</header>
</div>
</section>
</main>
<?php include 'footer.php'; ?>