-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofile.php
More file actions
57 lines (47 loc) · 1.38 KB
/
profile.php
File metadata and controls
57 lines (47 loc) · 1.38 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
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
<?php
// Start session
session_start();
// Check if user is logged in
if (!isset($_SESSION["user_name"])) {
header("Location: login.php");
exit;
}
// Include the database connection file
include "db_conn.php";
// Fetch user information from the database
$user_name = $_SESSION["user_name"];
$sql = "SELECT name, email, language, domain_of_interest FROM users WHERE user_name = ?";
if ($stmt = $conn->prepare($sql)) {
// Bind variables to the prepared statement as parameters
$stmt->bind_param("s", $user_name);
// Attempt to execute the prepared statement
if ($stmt->execute()) {
// Store result
$stmt->store_result();
// Bind result variables
$stmt->bind_result($name, $email, $language, $domain_of_interest);
// Fetch values
$stmt->fetch();
} else {
echo "Oops! Something went wrong. Please try again later.";
}
// Close statement
$stmt->close();
}
// Close connection
$conn->close();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>User Profile</title>
</head>
<body>
<h2>Welcome, <?php echo $_SESSION['name'];?>!</h2>
<p>Your username: <?php echo $_SESSION['user_name']; ?></p>
<p>Email: <?php echo $_SESSION['name'];?></p>
<p><a href="logout.php">Logout</a></p>
</body>
</html>