Add profile picture support to account, login, and register pages

This commit is contained in:
Fabian Schieder 2026-01-25 17:34:15 +01:00
parent e6d70b59c3
commit 8e9246f66e
7 changed files with 26 additions and 7 deletions

View File

@ -27,7 +27,7 @@ if (!$conn)
die("Datenbankfehler"); die("Datenbankfehler");
} }
$stmt = mysqli_prepare($conn, "SELECT userID, displayName, email FROM users WHERE userID = ? LIMIT 1"); $stmt = mysqli_prepare($conn, "SELECT userID, displayName, email, profilePicture FROM users WHERE userID = ? LIMIT 1");
if (!$stmt) if (!$stmt)
{ {
http_response_code(500); http_response_code(500);
@ -66,12 +66,20 @@ include 'header.php';
<main class="auth" role="main"> <main class="auth" role="main">
<section class="auth__grid" aria-label="Account Bereich"> <section class="auth__grid" aria-label="Account Bereich">
<div class="auth__card">
<header class="auth__header">
<img src="<?php echo htmlspecialchars($user['profilePicture']); ?>"
alt="Profilbild"
width="475">
</header>
</div>
<div class="auth__card"> <div class="auth__card">
<header class="auth__header"> <header class="auth__header">
<p class="auth__title"> <p class="auth__title">
Username: <?php echo htmlspecialchars($user['displayName'], ENT_QUOTES, 'UTF-8'); ?></p> <br> 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">UserID: <?php echo (int)$user['userID']; ?></p> <br>
<p class="auth__title">Email: <?php echo htmlspecialchars($user['email']); ?></p> <p class="auth__title">Email: <?php echo htmlspecialchars($user['email']); ?></p> <br>
</header> </header>
</div> </div>
</section> </section>

View File

@ -83,7 +83,7 @@
line-height: 1.4; line-height: 1.4;
} }
.auth__alert{ .auth__alert__error{
margin: 12px 0 14px; margin: 12px 0 14px;
color: #ffffff; color: #ffffff;
background: var(--gh-danger); background: var(--gh-danger);
@ -92,6 +92,15 @@
box-shadow: 0 8px 18px rgba(217, 45, 32, 0.18); box-shadow: 0 8px 18px rgba(217, 45, 32, 0.18);
} }
.auth__alert__sucess{
margin: 12px 0 14px;
color: #ffffff;
background: #558346;
border-radius: 12px;
padding: 10px 12px;
box-shadow: 0 8px 18px rgba(72, 142, 62, 0.18);
}
.auth__form{ .auth__form{
margin-top: 6px; margin-top: 6px;
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 MiB

View File

@ -117,12 +117,12 @@ include 'header.php';
</header> </header>
<?php if ($loginInfo): ?> <?php if ($loginInfo): ?>
<p class="auth__alert" <p class="auth__alert__sucess"
role="status"><?php echo htmlspecialchars($loginInfo, ENT_QUOTES, 'UTF-8'); ?></p> role="status"><?php echo htmlspecialchars($loginInfo, ENT_QUOTES, 'UTF-8'); ?></p>
<?php endif; ?> <?php endif; ?>
<?php if ($loginError): ?> <?php if ($loginError): ?>
<p class="auth__alert" <p class="auth__alert__error"
role="alert"><?php echo htmlspecialchars($loginError, ENT_QUOTES, 'UTF-8'); ?></p> role="alert"><?php echo htmlspecialchars($loginError, ENT_QUOTES, 'UTF-8'); ?></p>
<?php endif; ?> <?php endif; ?>

View File

@ -53,6 +53,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST')
$pw2 = (string)$_POST['pw2']; $pw2 = (string)$_POST['pw2'];
} }
$profilePicture = 'assets/images/profilePictures/default.png';
$values['email'] = $email; $values['email'] = $email;
$values['displayName'] = $displayName; $values['displayName'] = $displayName;
@ -124,7 +126,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST')
$hash = password_hash($pw, PASSWORD_DEFAULT); $hash = password_hash($pw, PASSWORD_DEFAULT);
$stmt = mysqli_prepare( $stmt = mysqli_prepare(
$conn, $conn,
'INSERT INTO users (email, passwordHash, displayName, isActive, createdAt) VALUES (?, ?, ?, 1, NOW())' "INSERT INTO users (email, passwordHash, displayName, isActive, createdAt, profilePicture) VALUES (?, ?, ?, 1, NOW(), ?)"
); );
if (!$stmt) if (!$stmt)
@ -133,7 +135,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST')
} }
else else
{ {
mysqli_stmt_bind_param($stmt, 'sss', $email, $hash, $displayName); mysqli_stmt_bind_param($stmt, 'ssss', $email, $hash, $displayName, $profilePicture);
$ok = mysqli_stmt_execute($stmt); $ok = mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt); mysqli_stmt_close($stmt);