-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmy_account.php
165 lines (156 loc) · 8.55 KB
/
my_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
<?php
include 'admin/db_connect.php';
?>
<style>
.masthead{
min-height: 23vh !important;
height: 23vh !important;
}
.masthead:before{
min-height: 23vh !important;
height: 23vh !important;
}
img#cimg{
max-height: 10vh;
max-width: 6vw;
}
</style>
<header class="masthead">
<div class="container-fluid h-100">
<div class="row h-100 align-items-center justify-content-center text-center">
<div class="col-lg-8 align-self-end mb-4 page-title">
<h3 class="text-white">Manage Account</h3>
<hr class="divider my-4" />
<div class="col-md-12 mb-2 justify-content-center">
</div>
</div>
</div>
</div>
</header>
<div class="container mt-3 pt-2">
<div class="col-lg-12">
<div class="card mb-4">
<div class="card-body">
<div class="container-fluid">
<div class="col-md-12">
<form action="" id="update_account">
<div class="row form-group">
<div class="col-md-4">
<label for="" class="control-label">Last Name</label>
<input type="text" class="form-control" name="lastname" value="<?php echo $_SESSION['bio']['lastname'] ?>" required>
</div>
<div class="col-md-4">
<label for="" class="control-label">First Name</label>
<input type="text" class="form-control" name="firstname" value="<?php echo $_SESSION['bio']['firstname'] ?>" required>
</div>
<div class="col-md-4">
<label for="" class="control-label">Middle Name</label>
<input type="text" class="form-control" name="middlename" value="<?php echo $_SESSION['bio']['middlename'] ?>" >
</div>
</div>
<div class="row form-group">
<div class="col-md-4">
<label for="" class="control-label">Gender</label>
<select class="custom-select" name="gender" required>
<option <?php echo $_SESSION['bio']['gender'] =='Male' ? 'selected' : '' ?>>Male</option>
<option <?php echo $_SESSION['bio']['gender'] =='Female' ? 'selected' : '' ?>>Female</option>
</select>
</div>
<div class="col-md-4">
<label for="" class="control-label">Batch</label>
<input type="input" class="form-control datepickerY" name="batch" value="<?php echo $_SESSION['bio']['batch'] ?>" required>
</div>
<div class="col-md-4">
<label for="" class="control-label">Course Graduated</label>
<select class="custom-select select2" name="course_id" required>
<option></option>
<?php
$course = $conn->query("SELECT * FROM courses order by course asc");
while($row=$course->fetch_assoc()):
?>
<option value="<?php echo $row['id'] ?>" <?php echo $_SESSION['bio']['course_id'] ==$row['id'] ? 'selected' : '' ?>><?php echo $row['course'] ?></option>
<?php endwhile; ?>
</select>
</div>
</div>
<div class="row form-group">
<div class="col-md-5">
<label for="" class="control-label">Currently Connected To</label>
<textarea name="connected_to" id="" cols="30" rows="3" class="form-control"><?php echo $_SESSION['bio']['connected_to'] ?></textarea>
</div>
<div class="col-md-5">
<label for="" class="control-label">Image</label>
<input type="file" class="form-control" name="img" onchange="displayImg(this,$(this))">
<img src="admin/assets/uploads/<?php echo $_SESSION['bio']['avatar'] ?>" alt="" id="cimg">
</div>
</div>
<div class="row">
<div class="col-md-4">
<label for="" class="control-label">Email</label>
<input type="email" class="form-control" name="email" value="<?php echo $_SESSION['bio']['email'] ?>" required>
</div>
<div class="col-md-4">
<label for="" class="control-label">Password</label>
<input type="password" class="form-control" name="password">
<small><i>Leave this blank if you dont want to change your password</i></small>
</div>
</div>
<div id="msg">
</div>
<hr class="divider">
<div class="row">
<div class="col-md-12 text-center">
<button class="btn btn-primary">Update Account</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
$('.datepickerY').datepicker({
format: " yyyy",
viewMode: "years",
minViewMode: "years"
})
$('.select2').select2({
placeholder:"Please Select Here",
width:"100%"
})
function displayImg(input,_this) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#cimg').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
$('#update_account').submit(function(e){
e.preventDefault()
start_load()
$.ajax({
url:'admin/ajax.php?action=update_account',
data: new FormData($(this)[0]),
cache: false,
contentType: false,
processData: false,
method: 'POST',
type: 'POST',
success:function(resp){
if(resp == 1){
alert_toast("Account successfully updated.",'success');
setTimeout(function(){
location.reload()
},700)
}else{
$('#msg').html('<div class="alert alert-danger">email already exist.</div>')
end_load()
}
}
})
})
</script>