-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile.php
61 lines (49 loc) · 1.47 KB
/
profile.php
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php include 'include/header.php' ?>
<?php
session_start();
$host = "localhost";
$user = "root";
$password = "";
$dbname = "foodpicky_db";
$conn = mysqli_connect($host, $user, $password, $dbname);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
// Get user information from database
$id = $_SESSION["user_id"];
// die($id);
$sql = "SELECT * FROM users WHERE u_id=$id";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
$row = mysqli_fetch_assoc($result);
$username = $row['username'];
$email = $row['email'];
$phone = $row['phone'];
$address = $row['address'];
} else {
echo "Error: User not found.";
}
mysqli_close($conn);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<link href="newstyle.css" rel="stylesheet">
<title>User Profile</title>
</head>
<body>
<div class="profile-wrapper">
<div class="profile-content" style="margin:10px;">
<h1>Welcome <?php echo $username; ?>!</h1>
<div class="profile-details">
<p><strong>Username:</strong> <?php echo $username; ?></p>
<p><strong>Email:</strong> <?php echo $email; ?></p>
<p><strong>Phone:</strong> <?php echo $phone; ?></p>
<p><strong>Address:</strong> <?php echo $address; ?></p>
</div>
<a href="update_profile.php" class="edit-profile-btn">Edit Profile</a>
</div>
</div>
</body>
</html>
<?php include 'include/footer.php' ?>