forked from tasminoni/CSE370-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofile.php
144 lines (108 loc) · 3.13 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
session_start();
$servername = "localhost";
$username = "root";
$password = "";
$database = "db";
$mysqli = new mysqli($servername, $username, $password, $database);
if (!$mysqli) {
echo "Error connecting to the database. Please try again later.";
exit;
}
$emailQuery = "SELECT email FROM userinfo ORDER BY id DESC LIMIT 1";
$result = $mysqli->query($emailQuery);
if ($result) {
$row = $result->fetch_assoc();
$latestEmail = $row['email'];
$userDataQuery = "SELECT * FROM user WHERE email = '$latestEmail'";
$userDataResult = $mysqli->query($userDataQuery);
if ($userDataResult && $userDataResult->num_rows > 0) {
$user = $userDataResult->fetch_assoc();
$name = $user['name'];
$email=$user['email'];
} else {
echo "No user found with the latest email.";
exit;
}
} else {
echo "Error executing query: " . $mysqli->error;
exit;
}
?>
<!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>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f5f5f5;
margin: 0;
padding: 0;
box-sizing: border-box;
}
.container {
max-width: 600px;
margin: 50px auto;
padding: 20px;
background-color: #fff;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
text-align: center;
}
h1 {
color: #333;
}
.user-info {
display: flex;
flex-direction: column;
align-items: flex-start;
margin-bottom: 20px;
}
p {
margin: 5px 0;
color: #666;
text-align: left;
}
.button {
background-color: #4CAF50; /* Green */
border: none;
color: white;
padding: 10px 20px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
border-radius: 8px;
}
.button:hover {
background-color: #45a049;
}
.logout-btn {
background-color: #f44336; /* Red */
}
body {
background-image: url('images/img.jpeg');
background-size: cover;
background-repeat: no-repeat;
}
</style>
</head>
<body>
<div class="container">
<h1>User Profile</h1>
<div class="user-info">
<p><strong>Name:</strong> <?php echo $name; ?></p>
<p><strong>Email:</strong> <?php echo $email; ?></p>
</div>
<button class="button" onclick="location.href='loginhome.html';">Exit</button>
<form method="post" action="logout.php" style="display: inline;">
<button class="button logout-btn" type="submit">Logout</button>
</form>
</div>
</body>
</html>