-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile.php
211 lines (197 loc) · 11.1 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
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
209
210
211
<?php
include "src/header.php";
if (isset($_SESSION["user_role"]) || $_GET["email"]) {
if ($_SESSION["user_role"] != "admin") {
echo '<script>';
echo 'location.href = "index.php";';
echo '</script>';
}
}
$userEmail = $_GET["email"];
$userQuery = "SELECT * FROM user WHERE email ='".$userEmail."'; ";
$execUserQuery = mysqli_query($conn, $userQuery);
$userData = mysqli_fetch_array($execUserQuery);
if (mysqli_num_rows($execUserQuery)==0) {
echo '<script>';
echo 'location.href = "index.php";';
echo '</script>';
}
?>
<style>
.role {
color: white;
}
</style>
<!-- ============================================================== -->
<!-- Page wrapper -->
<!-- ============================================================== -->
<div class="page-wrapper">
<!-- ============================================================== -->
<!-- Bread crumb and right sidebar toggle -->
<!-- ============================================================== -->
<div class="page-breadcrumb">
<div class="row">
<div class="col-7 align-self-center">
<h4 class="page-title text-truncate text-dark font-weight-medium mb-1">User Profile</h4>
<div class="d-flex align-items-center">
<nav aria-label="breadcrumb">
<ol class="breadcrumb m-0 p-0">
<li class="breadcrumb-item text-muted active" aria-current="page">User Profile Detail</li>
</ol>
</nav>
</div>
</div>
</div>
</div>
<!-- ============================================================== -->
<!-- End Bread crumb and right sidebar toggle -->
<!-- ============================================================== -->
<!-- ============================================================== -->
<!-- Container fluid -->
<!-- ============================================================== -->
<div class="container-fluid">
<!-- ============================================================== -->
<!-- Start Page Content -->
<!-- ============================================================== -->
<div class="row">
<!-- Start List Directory Table -->
<div class="col-12">
<div class="card">
<div class="card-body">
<form action="#" class="pl-3 pr-3 row">
<div class="form-group col-md-6">
<label for="">Email</label>
<input type="hidden" class="form-control" placeholder="Email" id="email_param"
name="email_param" required="" maxlength="255" value="<?php echo $userData["email"]; ?>">
<input type="email" class="form-control" placeholder="Email" id="email"
name="email" required="" maxlength="255" value="<?php echo $userData["email"]; ?>">
<div class="invalid-feedback" id="email-error-format" style="display: none">
Email is not in valid format!
</div>
<div class="invalid-feedback" id="email-error-null" style="display: none">
Email is required!
</div>
<div class="invalid-feedback" id="email-error-exist" style="display: none">
Email already exist, please insert another Email.
</div>
</div>
<div class="form-group col-md-6">
<label for="">Username</label>
<input type="hidden" class="form-control" placeholder="Username" id="username_param"
name="username_param" required="" maxlength="255" value="<?php echo $userData["username"]; ?>">
<input type="text" class="form-control" placeholder="Username" id="username"
name="username" required="" maxlength="255" value="<?php echo $userData["username"]; ?>">
<div class="invalid-feedback" id="username-error-null" style="display: none">
Username is required!
</div>
<div class="invalid-feedback" id="username-error-exist" style="display: none">
Username already exist, please insert another Username.
</div>
</div>
<div class="form-group col-md-6">
<label for="">Full Name</label>
<input type="text" class="form-control" placeholder="Full Name" id="fullname"
name="fullname" required="" maxlength="255" value="<?php echo $userData["fullname"]; ?>">
<div class="invalid-feedback" id="fullname-error-null" style="display: none">
Full Name is required!
</div>
</div>
<div class="form-group col-md-6">
<label for="">Role</label>
<?php if ($_SESSION["user_role"] == "admin") { ?>
<h3><button type="button" class="btn btn-primary">Admin</button></h3>
<?php } ?>
<?php if ($_SESSION["user_role"] == "user") { ?>
<h3><button type="button" class="btn btn-warning">User</button></h3>
<?php } ?>
</div>
<div class="form-group col-md-6">
<label for="">Password</label>
<span class="input-group-btn">
<div class="btn-group btn-group-sm" role="group" aria-label="Basic example">
<button type="button" class="btn btn-success" data-toggle="modal" data-target="#change-pass-modal"><i class="fas fa-pencil-alt"></i></button>
</div>
</span>
<input type="password" class="form-control" placeholder="************" id="password"
name="password" required="" maxlength="255" disable="" readonly>
</div>
<div class="form-group text-center col-md-12">
<button class="btn btn-rounded btn-success" type="button" id="userUpdate">Update</button>
<a href="index.php" class="btn btn-rounded btn-danger">Cancel</a>
</div>
</form>
</div>
</div>
</div>
<!-- End List Directory Table -->
</div>
<!-- ============================================================== -->
<!-- End PAge Content -->
<!-- ============================================================== -->
<!-- ============================================================== -->
<!-- Right sidebar -->
<!-- ============================================================== -->
<!-- .right-sidebar -->
<!-- ============================================================== -->
<!-- End Right sidebar -->
<!-- ============================================================== -->
</div>
<!-- ============================================================== -->
<!-- End Container fluid -->
<!-- ============================================================== -->
</div>
<!-- ============================================================== -->
<!-- End Page wrapper -->
<!-- ============================================================== -->
<?php
include "src/footer.php";
?>
<script src="src/dist/js/ajaxForm/profileUpdate.js"></script>
<script src="src/dist/js/ajaxForm/updatePassword.js"></script>
</body>
<!-- Change Pass modal content -->
<div id="change-pass-modal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-body">
<form action="#" class="pl-3 pr-3">
<div class="form-group">
<label for="currentPassword">Password</label>
<input class="form-control" type="password" required=""
id="current-password" name="currentPassword" placeholder="Enter your current password">
<div class="invalid-feedback" id="password-error-null" style="display: none">
Password is required
</div>
<div class="invalid-feedback" id="password-error-wrong" style="display: none">
Wrong password
</div>
</div>
<div class="form-group">
<label for="password1">New Password</label>
<input class="form-control" type="password" required=""
id="new-password" name="newPassword" placeholder="Enter your new password">
<div class="invalid-feedback" id="new-password-error-null" style="display: none">
Password is required
</div>
</div>
<div class="form-group">
<label for="password1">Confirm Password</label>
<input class="form-control" type="password" required=""
id="confirm-password" name="confirmPassword" placeholder="Confirm your new password">
<div class="invalid-feedback" id="confirm-password-error-null" style="display: none">
Confirm password is required
</div>
<div class="invalid-feedback" id="confirm-password-error-match" style="display: none">
Password and confirm password do not matched
</div>
</div>
<div class="form-group text-center">
<button class="btn btn-rounded btn-primary" type="button" id="passwordUpdate">Update Password</button>
<button class="btn btn-rounded btn-danger" type="button" data-dismiss="modal">Cancel</button>
</div>
</form>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</html>