-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.php
More file actions
27 lines (22 loc) · 784 Bytes
/
index.php
File metadata and controls
27 lines (22 loc) · 784 Bytes
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
<?php
session_start();
// Simulating logged-in user (Bob with user_id=2)
$_SESSION['user_id'] = 2;
// Set a cookie for the logged-in user (Bob)
setcookie('user_id', $_SESSION['user_id'], time() + (86400 * 30), "/");
// Simulated user database
$users = [
1 => ['name' => 'Alice', 'role' => 'admin'],
2 => ['name' => 'Bob', 'role' => 'user'],
3 => ['name' => 'Charlie', 'role' => 'user']
];
echo "<h1>Welcome, Bob!</h1>";
echo "<p>Select a user to view or edit their profile:</p>";
// List all users with view and edit links
foreach ($users as $id => $user) {
echo "<p>
<a href='view_profile.php?user_id=$id'>View Profile: {$user['name']}</a> |
<a href='edit_profile.php?user_id=$id'>Edit Profile: {$user['name']}</a>
</p>";
}
?>