-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
80 lines (69 loc) · 2.03 KB
/
index.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
session_start();
if (!isset($_SESSION["username"]) and !isset($_SESSION["email"])) {
header("Location: login.html");
exit();
}
$servername = "localhost"; //
$username = "root"; // Replace with your MySQL username
$password = ""; // Replace with your MySQL password
$dbname = "irp"; // Replace with your MySQL database name
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$username = $_SESSION["username"];
// Fetch user data based on username or email
$sql = "SELECT * FROM users WHERE (username='$username' or email='$username')";
$result = $conn->query($sql);
if ($result->num_rows == 1) {
$row = $result->fetch_assoc();
$name = $row["name"];
$username = $row["username"];
$email = $row["email"];
$gender = $row["gender"];
$dob = $row["dob"];
} else {
// found (This shouldn't happen if session is properly managed)
header("Location: login.html");
exit();
}
$conn->close();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Profile</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="profile-container">
<h2>Profile Details</h2>
<div class="profile-details">
<label for="name">Name:</label>
<span><?php echo $name; ?></span>
</div>
<div class="profile-details">
<label for="username">Username:</label>
<span><?php echo $username; ?></span>
</div>
<div class="profile-details">
<label for="email">Email:</label>
<span><?php echo $email; ?></span>
</div>
<div class="profile-details">
<label for="gender">Gender:</label>
<span><?php echo $gender; ?></span>
</div>
<div class="profile-details">
<label for="dob">Date of Birth:</label>
<span ><?php echo $dob; ?></span>
</div>
<a href="logout.php" class="logout-btn">Logout</a>
</div>
</body>
</html>