-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanage_user.php
66 lines (60 loc) · 2.13 KB
/
manage_user.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
<?php
include('db_connect.php');
session_start();
$utype = array('','users','staff','customers');
if(isset($_GET['id'])){
$user = $conn->query("SELECT * FROM {$utype[$_SESSION['login_type']]} where id =".$_GET['id']);
foreach($user->fetch_array() as $k =>$v){
$meta[$k] = $v;
}
}
?>
<div class="container-fluid">
<div id="msg"></div>
<form action="" id="manage-user">
<input type="hidden" name="id" value="<?php echo isset($meta['id']) ? $meta['id']: '' ?>">
<div class="form-group">
<label for="name">First Name</label>
<input type="text" name="firstname" id="firstname" class="form-control" value="<?php echo isset($meta['firstname']) ? $meta['firstname']: '' ?>" required>
</div>
<div class="form-group">
<label for="name">Middle Name</label>
<input type="text" name="middlename" id="middlename" class="form-control" value="<?php echo isset($meta['middlename']) ? $meta['middlename']: '' ?>">
</div>
<div class="form-group">
<label for="name">Last Name</label>
<input type="text" name="lastname" id="lastname" class="form-control" value="<?php echo isset($meta['lastname']) ? $meta['lastname']: '' ?>" required>
</div>
<div class="form-group">
<label for="username">Email</label>
<input type="text" name="email" id="email" class="form-control" value="<?php echo isset($meta['email']) ? $meta['email']: '' ?>" required autocomplete="off">
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" name="password" id="password" class="form-control" value="" autocomplete="off">
<small><i>Leave this blank if you dont want to change the password.</i></small>
</div>
</form>
</div>
<script>
$('#manage-user').submit(function(e){
e.preventDefault();
start_load()
$.ajax({
url:'ajax.php?action=update_user',
method:'POST',
data:$(this).serialize(),
success:function(resp){
if(resp ==1){
alert_toast("Data successfully saved",'success')
setTimeout(function(){
location.reload()
},1500)
}else{
$('#msg').html('<div class="alert alert-danger">Username already exist</div>')
end_load()
}
}
})
})
</script>