-
Notifications
You must be signed in to change notification settings - Fork 3
/
manage_account.php
212 lines (211 loc) · 11.6 KB
/
manage_account.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
212
<?php
if($_settings->userdata('id') > 0 && $_settings->userdata('login_type') == 2){
$qry = $conn->query("SELECT * FROM `client_list` where id = '{$_settings->userdata('id')}'");
if($qry->num_rows >0){
$res = $qry->fetch_array();
foreach($res as $k => $v){
if(!is_numeric($k)){
$$k = $v;
}
}
}else{
echo "<script> alert('You are not allowed to access this page. Unknown User ID.'); location.replace('./') </script>";
}
}else{
echo "<script> alert('You are not allowed to access this page.'); location.replace('./') </script>";
}
?>
<style>
#cimg{
width:15vw;
height:20vh;
object-fit:scale-down;
object-position:center center;
}
</style>
<div class="content py-5 mt-5">
<div class="container">
<div class="card card-outline card-purple shadow rounded-0">
<div class="card-header">
<h4 class="card-title"><b>Manage Account Details/Credentials</b></h4>
</div>
<div class="card-body">
<div class="container-fluid">
<form id="register-frm" action="" method="post">
<input type="hidden" name="id" value="<?= isset($id) ? $id : "" ?>">
<div class="row">
<div class="form-group col-md-6">
<input type="text" name="firstname" id="firstname" placeholder="Enter First Name" autofocus class="form-control form-control-sm form-control-border" value="<?= isset($firstname) ? $firstname : "" ?>" required>
<small class="ml-3">First Name</small>
</div>
<div class="form-group col-md-6">
<input type="text" name="middlename" id="middlename" placeholder="Enter Middle Name (optional)" class="form-control form-control-sm form-control-border" value="<?= isset($middlename) ? $middlename : "" ?>">
<small class="ml-3">Middle Name</small>
</div>
<div class="form-group col-md-6">
<input type="text" name="lastname" id="lastname" placeholder="Enter Last Name" class="form-control form-control-sm form-control-border" required value="<?= isset($lastname) ? $lastname : "" ?>">
<small class="ml-3">Last Name</small>
</div>
</div>
<div class="row">
<div class="form-group col-md-6">
<select name="gender" id="gender" class="custom-select custom-select-sm form-control-border" required>
<option <?= isset($gender) && $gender == 'Male' ? "selected" : "" ?>>Male</option>
<option <?= isset($gender) && $gender == 'Female' ? "selected" : "" ?>>Female</option>
</select>
<small class="ml-3">Gender</small>
</div>
<div class="form-group col-md-6">
<input type="text" name="contact" id="contact" placeholder="Enter Contact #" class="form-control form-control-sm form-control-border" required value="<?= isset($contact) ? $contact : "" ?>">
<small class="ml-3">Contact #</small>
</div>
</div>
<div class="row">
<div class="form-group col-md-12">
<small class="ml-3">Address</small>
<textarea name="address" id="address" rows="3" class="form-control form-control-sm rounded-0" placeholder="Block 6 Lot 23, Here Subd., There City, Anywhere, 2306"><?= isset($address) ? $address : "" ?></textarea>
</div>
</div>
<hr>
<div class="row">
<div class="form-group col-md-6">
<input type="email" name="email" id="email" placeholder="jsmith@sample.com" class="form-control form-control-sm form-control-border" required value="<?= isset($email) ? $email : "" ?>">
<small class="ml-3">Email</small>
</div>
</div>
<div class="row">
<div class="form-group col-md-6">
<div class="input-group">
<input type="password" name="password" id="password" placeholder="" class="form-control form-control-sm form-control-border">
<div class="input-group-append border-bottom border-top-0 border-left-0 border-right-0">
<span class="input-append-text text-sm"><i class="fa fa-eye-slash text-muted pass_type" data-type="password"></i></span>
</div>
</div>
<small class="ml-3">New Password</small>
</div>
<div class="form-group col-md-6">
<div class="input-group">
<input type="password" id="cpassword" placeholder="" class="form-control form-control-sm form-control-border">
<div class="input-group-append border-bottom border-top-0 border-left-0 border-right-0">
<span class="input-append-text text-sm"><i class="fa fa-eye-slash text-muted pass_type" data-type="password"></i></span>
</div>
</div>
<small class="ml-3">Confirm New Password</small>
</div>
<div class="col-12"><small class="text-muted"><em>Fill the password fields above only if you want to update your password.</em></small></div>
</div>
<div class="row">
<div class="form-group col-md-6">
<div class="input-group">
<input type="password" name="oldpassword" id="oldpassword" placeholder="" class="form-control form-control-sm form-control-border" required>
<div class="input-group-append border-bottom border-top-0 border-left-0 border-right-0">
<span class="input-append-text text-sm"><i class="fa fa-eye-slash text-muted pass_type" data-type="password"></i></span>
</div>
</div>
<small class="ml-3">Current Password</small>
</div>
</div>
<div class="row">
<div class="form-group col-md-6">
<label for="" class="control-label">Avatar</label>
<div class="custom-file">
<input type="file" class="custom-file-input rounded-0 form-control form-control-sm form-control-border" id="customFile" name="img" onchange="displayImg(this,$(this))">
<label class="custom-file-label" for="customFile">Choose file</label>
</div>
</div>
<div class="row">
</div>
<div class="form-group col-md-6 d-flex justify-content-center">
<img src="<?php echo validate_image(isset($image_path) ? $image_path : "") ?>" alt="" id="cimg" class="img-fluid img-thumbnail">
</div>
</div>
<div class="row align-items-center">
<div class="col-8">
</div>
<!-- /.col -->
<div class="col-4">
<button type="submit" class="btn btn-primary btn-sm btn-flat btn-block">Update Details</button>
</div>
<!-- /.col -->
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<script>
window.displayImg = function(input,_this) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#cimg').attr('src', e.target.result);
_this.siblings('.custom-file-label').html(input.files[0].name)
}
reader.readAsDataURL(input.files[0]);
}else{
$('#cimg').attr('src', "<?php echo validate_image(isset($image_path) ? $image_path : "") ?>");
_this.siblings('.custom-file-label').html("Choose file")
}
}
$(function(){
$('.pass_type').click(function(){
var type = $(this).attr('data-type')
if(type == 'password'){
$(this).attr('data-type','text')
$(this).closest('.input-group').find('input').attr('type',"text")
$(this).removeClass("fa-eye-slash")
$(this).addClass("fa-eye")
}else{
$(this).attr('data-type','password')
$(this).closest('.input-group').find('input').attr('type',"password")
$(this).removeClass("fa-eye")
$(this).addClass("fa-eye-slash")
}
})
$('#register-frm').submit(function(e){
e.preventDefault()
var _this = $(this)
$('.err-msg').remove();
var el = $('<div>')
el.hide()
if($('#password').val() != $('#cpassword').val()){
el.addClass('alert alert-danger err-msg').text('Password does not match.');
_this.prepend(el)
el.show('slow')
return false;
}
start_loader();
$.ajax({
url:_base_url_+"classes/Users.php?f=save_client",
data: new FormData($(this)[0]),
cache: false,
contentType: false,
processData: false,
method: 'POST',
type: 'POST',
dataType: 'json',
error:err=>{
console.log(err)
alert_toast("An error occured",'error');
end_loader();
},
success:function(resp){
if(typeof resp =='object' && resp.status == 'success'){
location.reload();
}else if(resp.status == 'failed' && !!resp.msg){
el.addClass("alert alert-danger err-msg").text(resp.msg)
_this.prepend(el)
el.show('slow')
}else{
alert_toast("An error occured",'error');
end_loader();
console.log(resp)
}
end_loader();
$('html, body').scrollTop(0)
}
})
})
})
</script>