Repository navigation
Expand file tree
/
Copy pathmyprofile.php
More file actions
103 lines (90 loc) · 3.58 KB
/
Copy pathmyprofile.php
File metadata and controls
103 lines (90 loc) · 3.58 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
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
<?php
// Handle sign-out button click
if (isset($_POST['sign-out-btn'])) {
// Destroy the session to log the user out
session_destroy();
// Redirect to the login page
header("Location: login.php");
exit();
}
session_start();
include("connection.php");
// Check if the user is logged in and the unique code is stored in the session
if (isset($_SESSION['unique_code'])) {
$unique_code = $_SESSION['unique_code'];
// Fetch the user's email from the database using the unique code
$sql = "SELECT username, email FROM users WHERE unique_code = '$unique_code'";
$result = $conn1->query($sql);
if ($result->num_rows == 1) {
// If a user with the unique code is found, retrieve the email
$row = $result->fetch_assoc();
$username = $row['username'];
$email = $row['email'];
} else {
// Redirect to the login page if the user is not found
header("Location: login.php");
exit();
}
} else {
// Redirect to the login page if the user is not logged in
header("Location: login.php");
exit();
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SmartREQ |My profile</title>
<link rel="icon" type="image/x-icon" href="images/favicon.ico">
<link rel="stylesheet" type="text/css" href="home.css">
<script src="loginscript.js"></script>
</head>
<body>
<div class="header">
<a href="home.php"><img src="images/smart REQ logo.png" alt="SmartREQ " class="logo"></a>
<a href="home.php" ><ion-icon name="home-sharp"></ion-icon></a>
<nav>
</nav>
</div>
<div class="sidebar">
<div class="user-info">
<?php
if (isset($_SESSION['username'])) {
echo "You are logged in as: " . $_SESSION['username'];
}
?>
</div>
<ul class="menu">
<li>
<a href="budgets.php"><ion-icon name="podium"></ion-icon> Budgets</a>
<a href="requisitions.php"><ion-icon name="newspaper"></ion-icon></ion-icon> Requisitions</a>
<a href="myprofile.php"><ion-icon name="person-circle-sharp"></ion-icon> Profile</a>
<a href="F.A.Qs.php"><ion-icon name="help-circle"></ion-icon> F.A.Qs</a>
<a href="reports.php"><ion-icon name="settings"></ion-icon> Reports</a>
</li>
</ul>
<form method="post">
<button type="submit" id="sign-out-btn" name="sign-out-btn"> <ion-icon name="log-out"></ion-icon> Sign Out</button>
</form>
</div>
<div class="main-content">
<!-- my profile content -->
<h1>My Profile </h1>
<form action="update_profile.php" method="POST">
<label for="username">Username:</label>
<input type="text" name="username" value="<?php echo $username; ?>" required><br>
<label for="email">Email:</label>
<input type="email" name="email" value="<?php echo $email; ?>" required><br>
<label for="new_password">New Password:</label>
<input type="password" name="new_password" required><br>
<label for="confirm_password">Confirm New Password:</label>
<input type="password" name="confirm_password" required><br>
<input type="submit" value="Save Changes">
</form>
</div>
<script type="module" src="https://unpkg.com/ionicons@7.1.0/dist/ionicons/ionicons.esm.js"></script>
<script nomodule src="https://unpkg.com/ionicons@7.1.0/dist/ionicons/ionicons.js"></script>
</body>
</html>