-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathedit_account.php
More file actions
151 lines (129 loc) · 5.46 KB
/
Copy pathedit_account.php
File metadata and controls
151 lines (129 loc) · 5.46 KB
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
<?php
$page_title = 'Edit Account';
require_once('includes/load.php');
page_require_level(3);
?>
<?php
//update user image
if(isset($_POST['submit'])) {
$photo = new Media();
$user_id = (int)$_POST['user_id'];
$photo->upload($_FILES['file_upload']);
if($photo->process_user($user_id)){
$session->msg('s','photo has been uploaded.');
redirect('profile.php?id='.$user_id);
} else{
$session->msg('d',join($photo->errors));
redirect('profile.php?id='.$user_id);
}
}
?>
<?php
//update user other info
if(isset($_POST['update'])){
$req_fields = array('name','username' );
validate_fields($req_fields);
if(empty($errors)){
$id = (int)$_SESSION['user_id'];
$name = remove_junk($db->escape($_POST['name']));
$username = remove_junk($db->escape($_POST['username']));
$sql = "UPDATE users SET name ='{$name}', username ='{$username}' WHERE id='{$id}'";
$result = $db->query($sql);
if($result && $db->affected_rows() === 1){
$session->msg('s',"Acount updated ");
redirect('edit_account.php', false);
} else {
$session->msg('d',' Sorry failed to updated!');
redirect('edit_account.php', false);
}
} else {
$session->msg("d", $errors);
redirect('edit_account.php',false);
}
}
?>
<?php include_once('layouts/header.php'); ?>
<!-- <link rel="stylesheet" href="libs/css/inventoryPopup.css"> -->
<!--
<?php echo display_msg($msg); ?>
-->
<!-- // Popup Start -->
<div class="addNewgGroupPopUpWap">
<div class="newgroupPopHeadWrap">
<div class="iconHeadGroup">
<img src="libs/logos/table-logo/user.png" alt="logo">
<div class="addPopGroupTitle">Edit Account</div>
</div>
<div class="addNewGroupContent">
<div class="addNewForm ">
<!-- Form : Image -->
<div class="formContainer">
<form action="edit_account.php" method="post" enctype="multipart/form-data">
<div class="wrapper">
<div class="inputGrup" style="margin-bottom: 0px">
<img class="img-circle img-size-2" src="uploads/users/<?php echo $user['image'];?>" alt="user-profile-image">
</div>
<!-- Browse -->
<div class="inputGrup" style="width: 250px">
<p>Click below to Browse Image</p>
<input type="file" name="file_upload" multiple="multiple" class="btn btn-default fileUpload" style="t" placeholder="Browse"/>
</div>
</div>
<div class="inputGrup" style="margin-bottom: 0px">
<input type="hidden" name="user_id" value="<?php echo $user['id'];?>">
<button type="submit" name="submit" class="btn upload-btn-profile">Upload</button>
</div>
</form>
</div>
<div class="formContainer">
<!-- Form : Name -->
<form method="post" action="edit_user.php?id=<?php echo (int)$user['id'];?>">
<div class="inputGrup" style="margin-bottom: 10px">
<label for="name">Name</label>
<input type="name" class="form-control" name="username" value="<?php echo remove_junk(ucwords($user['name'])); ?>">
</div>
<div class="inputGrup">
<label for="username">Username</label>
<input type="text" class="form-control" name="username" value="<?php echo remove_junk(ucwords($user['username'])); ?>">
</div>
<div class="">
<!-- <div class="cancelBtn">
<button type="button" id="cancelBtn">Cancel</button>
</div> -->
<div class="inputGrup" style="margin-bottom: 0px">
<button type="submit" name="update" class="btn upload-btn-profile">Update</button>
</div>
</div>
</form>
</div>
<div class="formContainer">
<!-- Form : Password -->
<form method="post" action="change_password.php" class="clearfix">
<div class="inputGrup" style="margin-bottom: 0px">
<label for="oldPassword" class="control-label">Old password</label>
<input type="password" class="form-control" name="old-password" placeholder="Old password">
</div>
<div class="inputGrup">
<label for="newPassword" class="control-label">New password</label>
<input type="password" class="form-control" name="new-password" placeholder="New password">
</div>
<div class="inputGrup">
<input type="hidden" name="id" value="<?php echo (int)$user['id'];?>">
<button type="submit" name="update" class="btn upload-btn-profile">Change</button>
</div>
</form>
<div class="">
<button type="button" id="cancelButton" class="cancelBtnX">Cancel</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- // Popup Close -->
<script>
document.getElementById('cancelButton').addEventListener('click', function() {
window.history.back();
});
</script>
<?php include_once('layouts/footer.php'); ?>