hackernewsclone/account/userprofile.php
2024-02-23 20:40:00 +00:00

68 lines
2.1 KiB
PHP
Executable file

<?php
// We need to use sessions, so you should always start sessions using the below code.
session_start();
include('../config.php');
// If the user is not logged in redirect to the login page...
if (!isset($_SESSION['loggedin'])) {
header('Location: index.php');
exit;
}
$con = mysqli_connect($servername, $username, $password, $dbname);
if (mysqli_connect_errno()) {
exit('Failed to connect to MySQL: ' . mysqli_connect_error());
}
$quersy = $con->query("SELECT bio FROM accounts WHERE username = '".htmlspecialchars($_GET['user'])."'");
$con->query("SELECT * FROM accounts WHERE username = '".htmlspecialchars($_GET['user'])."'");
while($rows = mysqli_fetch_assoc($quersy)) {
$userbio = htmlspecialchars($rows['bio']);
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Profile</title>
<link href="style.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css" integrity="sha512-xh6O/CkQoPOWDdYTDqeRdPCVd1SpvCA9XXcUnZS2FmJNp1coAFzvtCN9BmamE+4aHK8yyUHUSCcJHgXloTyT2A==" crossorigin="anonymous" referrerpolicy="no-referrer">
<style>
.hnlink {
text-decoration:none;
color: #09BC8A;
}
</style>
</head>
<body class="loggedin">
<nav class="navtop">
<div>
<h1><?= $siteName; ?></h1>
<a href="../index.php"><i class="fas fa-house"></i>Home</a>
<a href="profile.php"><i class="fas fa-user-circle"></i>Info</a>
<a href="../users.php"><i class="fas fa-users"></i>Users</a>
<a href="logout.php"><i class="fas fa-sign-out-alt"></i>Logout</a>
</div>
</nav>
<div class="content">
<h2>Profile of <?= htmlspecialchars($_GET['user']); ?></h2>
<div>
<table>
<tr>
<td>Username:</td>
<td><?=htmlspecialchars($_GET['user']);?></td>
</tr>
<tr>
<td>Bio:</td>
<td><?=$userbio; ?></td>
</tr>
</table>
</form>
</div>
</div>
</body>
</html>