-
Notifications
You must be signed in to change notification settings - Fork 0
/
adminmyprofile.php
208 lines (182 loc) · 8.52 KB
/
adminmyprofile.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<?php
require_once "config.php";
session_start();
function getUserDataByEmail($email, $conn) {
// Sanitize user input
$email = mysqli_real_escape_string($conn, $email);
// Fetch user data from the database based on the provided email
$sql = "SELECT * FROM adminuser WHERE EmailAddress = '$email'";
$result = $conn->query($sql);
if ($result->num_rows === 1) {
$row = $result->fetch_assoc();
return $row;
} else {
return false; // User not found
}
}
// Get the user data using the email stored in the session
$userData = getUserDataByEmail($_SESSION['email'], $conn);
// If user data is found, extract the values
if ($userData) {
$name = $userData['Name'];
$email = $userData['EmailAddress'];
$hashedPassword = $userData['Password'];
$Photoname = $userData['Photoname'];
$Position = $userData['Position'];
$profile = $userData['Photoname'];
$idd = $userData['ID'];
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin | My Profile</title>
<!-- Header Start -->
<?php include('adminpanelheader.php') ?>
<!-- Header End -->
<!-- Content Area -->
<!-- Your HTML body content here -->
<div class="col-md-10 admindetails">
<div class="container mt-4">
<h1>My Profile</h1>
<div class="container mt-4">
<div class="card mx-auto">
<div class="card-body">
<form action="#" method="post">
<div class="form-group">
<label for="name">Name:</label>
<input type="text" class="form-control" id="name" name="name" value="<?php echo htmlspecialchars($name); ?>" readonly>
</div>
<div class="form-group">
<label for="email">Email Address:</label>
<input type="email" class="form-control" id="email" name="email" value="<?php echo htmlspecialchars($email); ?>" readonly>
</div>
<div class="form-group">
<label for="email">Position</label>
<input type="email" class="form-control" id="email" name="email" value="<?php echo htmlspecialchars($Position); ?>" readonly>
</div>
<div class="form-group">
<label for="password">Password:</label>
<div class="input-group">
<input type="password" class="form-control" id="password" name="password" value="<?php echo htmlspecialchars($hashedPassword); ?>" readonly>
<div class="input-group-append">
<button type="button" class="btn btn-outline-secondary" id="showHideBtn">Show</button>
</div>
</div>
</div>
<div class="form-group">
<button type="button" class="btn btn-primary" name="action" id="btnInsertnewData" value="insert">Insert</button>
<button type="button" class="btn btn-primary" name="action" id="btnEditnewData" value="edit">Edit</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<div class="modal fade" id="mdlInsertData">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">Register new Admin</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<!-- Modal Body -->
<div class="modal-body">
<form action="adminsavenewdata.php" method="POST" enctype="multipart/form-data">
<div class="form-group">
<label for="newName">Name</label>
<input type="text" class="form-control" id="newName" name="newName" required>
</div>
<div class="form-group">
<label for="groupName">EmailAddress:</label>
<input type="text" class="form-control" id="newEmailAddress" name="newEmailAddress" required>
</div>
<div class="form-group">
<label for="activityLocation">Position:</label>
<input type="text" class="form-control" id="newPosition" name="newPosition" required>
</div>
<div class="form-group">
<label for="activityLocation">Password:</label>
<input type="password" class="form-control" id="newPassword" name="newPassword" required>
</div>
<div class="form-group">
<label for="profileImage">Upload Profile Image:</label>
<input type="file" class="form-control-file" id="profileImage" name="profileImage" required>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-info" id="saveChanges">Save</button>
</div>
</form>
</div>
</div>
</div>
</div>
<div class="modal fade" id="mdlEditData">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">Edit Profile</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<!-- Modal Body -->
<div class="modal-body">
<form action="admineditdata.php" method="POST" enctype="multipart/form-data">
<div class="form-group">
<input type="text" name="id" value="<?php echo htmlspecialchars($idd); ?>" hidden><br>
<label for="newName">Name</label>
<input type="text" class="form-control" id="newName" name="newName" value="<?php echo htmlspecialchars($name); ?>">
</div>
<div class="form-group">
<label for="groupName">EmailAddress:</label>
<input type="text" class="form-control" id="newEmailAddress" name="newEmailAddress" value="<?php echo htmlspecialchars($email); ?>" readonly>
</div>
<div class="form-group">
<label for="activityLocation">Position:</label>
<input type="text" class="form-control" id="newPosition" name="newPosition" value="<?php echo htmlspecialchars($Position); ?>">
</div>
<div class="form-group">
<label for="profileImage">Upload Profile Image:</label>
<input type="file" class="form-control-file" id="profileImage" name="profileImage" value="<?php echo htmlspecialchars($profile); ?>">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-info" id="saveChanges">Save Changes</button>
</div>
</form>
</div>
<?php
?>
</div>
</div>
</div>
<!-- end of Content Area -->
<!-- Footer Start -->
<?php include('adminpanelfooter.php') ?>
<!-- Footer End -->
<script>
document.addEventListener("DOMContentLoaded", function () {
const passwordInput = document.getElementById("password");
const showHideBtn = document.getElementById("showHideBtn");
showHideBtn.addEventListener("click", function () {
if (passwordInput.type === "password") {
passwordInput.type = "text";
showHideBtn.textContent = "Hide";
} else {
passwordInput.type = "password";
showHideBtn.textContent = "Show";
}
});
});
$("#btnInsertnewData").click(function (){
$("#mdlInsertData").modal("show")
});
$("#btnEditnewData").click(function (){
$("#mdlEditData").modal("show")
});
</script>