I’m trying to make a profile page that shows the users username, password and email. When I go to my local host it just displays a white screen. I have a homepage that does display the HTML page in a the php file so I don’t know what I did wrong this time.
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
session_start();
if ( !isset($_SESSION['loggedin']) ) {
header('Location: index.html');
exit;
}
$DATABASE_HOST = 'localhost';
$DATABASE_USER = 'root';
$DATABASE_PASS = '';
$DATABASE_NAME = 'dbname';
$con = mysqli_connect($DATABASE_HOST, $DATABASE_USER, $DATABASE_PASS, $DATABASE_NAME);
if (mysqli_connect_errno()) {
exit('Failed to connect to MySQL: ' . mysqli_connect_error());
}
$stmt = $con->prepare('SELECT password, email FROM users WHERE id = ?');
$stmt->bind_parem('i', $_SESSION['id']);
$stmt->execute();
$stmt->bind_result($password, $email);
$stmt->fetch();
$stmt->close();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Profile Page</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="" rel="stylesheet">
</head>
<body class="loggedin">
<nav class="navtop">
<div>
<h1>Website Title</h1>
<a href="profile.php"><i class="fas fa-user"></i>Profile</a>
<a href="logout.php"><i class="fas fa-sign-out-alt"></i>Logout</a>
</div>
</nav>
<div class="content">
<h2>Profile Page</h2>
<div>
<p>Your account details are below:</p>
<table>
<tr>
<td>Username:</td>
<td><?=$_SESSION['name']?></td>
</tr>
<tr>
<td>Password:</td>
<td><?=$password?></td>
</tr>
<tr>
<td>E-mail:</td>
<td><?=$email?></td>
</tr>
</table>
</div>
</div>
</body>
</html>
I’ve looked at the error log but I didn’t find any problems and I also removed some code step by step but I can’t find what the problem is. I also couldn’t find a user who had the same problem as me.