-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofile.php
More file actions
32 lines (31 loc) · 1.05 KB
/
profile.php
File metadata and controls
32 lines (31 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
require_once("settings.php");
session_start();
// Redirect to login if not logged in
if (!isset($_SESSION['username'])) {
header('Location: login.php');
exit();
}
if ($dbconn) {
$username = $_SESSION['username'];
$query = "SELECT * FROM user WHERE username = '" . mysqli_real_escape_string($dbconn, $username) . "'";
$result = mysqli_query($dbconn, $query);
if ($result && $result->num_rows > 0) {
$user = $result->fetch_assoc();
// Display user profile information
echo "<h2>Welcome, " . htmlspecialchars($user['username']) . "!</h2>";
echo "<p>Email: " . htmlspecialchars($user['email']) . "</p>";
echo "<p>Password: ". htmlspecialchars($user["password"]) . "</p>";
// Add update profile button
echo '<form action="update_profile.php" method="get">';
echo '<button type="submit">Update Profile</button>';
echo '</form>';
} else {
echo "User not found.";
}
}
else{
die('Database connection failed: ' . $dbconn->connect_error);
}
mysqli_close($dbconn);
?>