-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathedit_admin.php
More file actions
410 lines (329 loc) · 17.3 KB
/
edit_admin.php
File metadata and controls
410 lines (329 loc) · 17.3 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
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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
<?php include('includes/database.php'); ?>
<?php
if (isset($_COOKIE["logged_in"])) {
$isSuperAdmin = $_COOKIE["logged_in"];
}
if (!(isset($_COOKIE["logged_in"])) || $isSuperAdmin==0) {
header("Location:index.php");
}
if (isset($_GET['logout'])) {
setcookie("logged_in", '', time() - (86400 * 30), "/");
header("Location:index.php");
}
if(!isset($_GET['user'])){
echo "<center><h1>ID not found</h1></center>";
exit(0);
}
//Assign get variable
$usr = $_GET['user']; //get user id form url
//Create customer select query
$query = "SELECT * FROM persons
WHERE Username = '$usr'";
$result = $mysqli->query($query) or die ($mysqli->error . " " . __LINE__);
if ($result = $mysqli->query($query)) {
//Fetch object arrauy
while ($row = $result->fetch_assoc()) {
$username = $row['Username'];
$first_name = $row['fname'];
$last_name = $row['lname'];
$address = $row['address'];
$email = $row['Email_id'];
$zipcode = $row['zip'];
$gender = $row["gender"];
$city = $row['city'];
$state = $row['state'];
$phone_number = $row['phone_number'];
$dob = $row['date_of_birth'];
$doj = $row['date_of_join'];
$emp_status = $row['employee_status'];
$designation = $row['designation'];
$emp_status_change = $row['employee_status_change'];
$bank_name = $row['bank_name'];
$bank_accno = $row['bank_accno'];
$bank_branch = $row['bank_branch'];
$ifsc = $row['ifsc_code'];
$micr = $row['micr_code'];
$isSuperadmin = $row['super_admin'];
}
//Free Result set
$result->close();
}
?>
<?php
if ($_POST) { //to check if form is submitted
//Assign get variable
$pFlag = 0;
$username = mysqli_real_escape_string($mysqli, $_POST['username']);
$first_name = mysqli_real_escape_string($mysqli, $_POST["first_name"]);
$last_name = mysqli_real_escape_string($mysqli, $_POST["last_name"]);
$email = mysqli_real_escape_string($mysqli, $_POST['email']);
$pwd = mysqli_real_escape_string($mysqli, $_POST['password']);
if ($pwd == "")
$pFlag = 0;
else {
$pwd = md5($pwd);
$pFlag = 1;
}
$gender = mysqli_real_escape_string($mysqli, $_POST["gender"]);
$zipcode = mysqli_real_escape_string($mysqli, $_POST["zip"]);
$address = mysqli_real_escape_string($mysqli, $_POST["address"]);
$city = mysqli_real_escape_string($mysqli, $_POST["city"]);
$state = mysqli_real_escape_string($mysqli, $_POST["state"]);
$phone_number = mysqli_real_escape_string($mysqli, $_POST["phoneno"]);
$dob = mysqli_real_escape_string($mysqli, $_POST['dob']);
$doj = mysqli_real_escape_string($mysqli, $_POST["doj"]);
$emp_status = mysqli_real_escape_string($mysqli, $_POST['status1']);
$designation = mysqli_real_escape_string($mysqli, $_POST['designation']);
$emp_status_change = mysqli_real_escape_string($mysqli, $_POST['statuschange']);
$bank_name = mysqli_real_escape_string($mysqli, $_POST['bankname']);
$bank_accno = mysqli_real_escape_string($mysqli, $_POST['ac']);
$bank_branch = mysqli_real_escape_string($mysqli, $_POST['bbranch']);
$ifsc = mysqli_real_escape_string($mysqli, $_POST['ifsc']);
$micr = mysqli_real_escape_string($mysqli, $_POST['micr']);
$isSuperadmin = mysqli_real_escape_string($mysqli, $_POST['superadmin']);
//Create employee update
$query = "UPDATE persons
SET
Username = '$username',
fname = '$first_name',
lname = '$last_name',
gender = '$gender',
Email_id = '$email',
address = '$address',
date_of_birth = '$dob',
zip = $zipcode,
city = '$city',
state = '$state',
phone_number = '$phone_number',
date_of_join = '$doj',
employee_status = '$emp_status',
designation = '$designation',
employee_status_change = '$emp_status_change',
bank_name = '$bank_name',
bank_accno = $bank_accno,
bank_branch = '$bank_branch',
ifsc_code = '$ifsc',
micr_code = '$micr',
super_admin = $isSuperadmin WHERE Username='$usr';
";
$mysqli->query($query) or die($mysqli->error . " " . __LINE__);
if($pFlag == 1){
$query = "UPDATE persons
SET Password = '$pwd' WHERE Username = '$usr'";
$mysqli->query($query) or die($mysqli->error . " " . __LINE__);
}
$msg = "Admin Updated";
header("Location:admin_manager.php?msg=" . urlencode($msg) . "");
exit;
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>CManager | Edit Admin</title>
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="css/jumbotron-narrow.css" rel="stylesheet">
<script type="text/javascript"
src="https://gc.kis.v2.scr.kaspersky-labs.com/67704677-3063-5142-AA2E-39311A24A375/main.js"
charset="UTF-8"></script>
<script type="text/javascript" src="validate3.js"></script>
</head>
<body>
<form method="get" action="edit_admin.php">
<div class="container">
<header class="header clearfix">
<nav>
<ul class="nav nav-pills float-right">
<li class="nav-item">
<a class="nav-link" href="index.php" style="color:#673ab7">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="admin_manager.php" style="color:#673ab7">Manager <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link active" href="" style="background-color:#673ab7">Edit Admin</a>
</li>
<li class="show1" style="padding-left: 10px;">
<input type="submit" value="Logout" class="btn btn-default navbar-btn" name="logout" >
</li>
</ul>
</nav>
<h3 class="text-muted">Store CManager</h3>
</header>
</form>
<main role="main">
<div class="row marketing">
<div class="col-lg-12">
<h2>Edit Admin </h2>
<form method="post" name="data" action="edit_admin.php?user=<?php echo $username; ?>">
<div class="form-group">
<label>Username</label>
<input name="username" type="text" class="form-control" placeholder="Enter Username"
onblur="fun0();"value="<?php echo $username?>">
<input name="uname" type="text" class="form-control" disabled>
</div>
<div class="form-group">
<label>First Name</label>
<input name="first_name" type="text" class="form-control" placeholder="Enter First Name"
onkeyup="fun();" value="<?php echo $first_name; ?>">
<input name="fname" type="text" class="form-control" disabled>
</div>
<div class="form-group">
<label>Last Name</label>
<input name="last_name" type="text" class="form-control" placeholder="Enter Last Name"
onkeyup="fun2();" value="<?php echo $last_name; ?>">
<input name="lname" type="text" class="form-control" disabled>
</div>
<div class="form-group">
<label>Gender</label>
<div class="radio">
<input name="gender" type="radio" class="radio" value="Male" onclick="fun7()"
<?php $a = ($gender == 'Male') ? 'checked' : ' ';
echo $a; ?>>
 
<label class="radio-inline">Male</label> 
<input name="gender" type="radio" class="radio" value="Female" onclick="fun7()"
<?php $a = ($gender == 'Female') ? 'checked' : ' ';
echo $a; ?>> 
<label class="radio-inline">Female</label> 
<input name="gender" type="radio" class="radio" value="Other" onclick="fun7()"
<?php $a = ($gender == 'Other') ? 'checked' : ' ';
echo $a; ?>> 
<label class="radio-inline">Other</label> 
</div>
</div>
<div class="form-group">
<label>Phone Number</label>
<input name="phoneno" maxlength="10" type="text" class="form-control"
placeholder="Enter Phone Number" onkeyup="fun3();" value="<?php echo $phone_number; ?>">
<input name="phno" type="text" class="form-control" disabled>
</div>
<div class="form-group">
<label>Date of Birth</label>
<input name="dob" type="date" class="form-control" placeholder="Enter Date of Birth"
max="<?php echo date("Y-m-d"); ?>" onblur="fun101()" value="<?php echo $dob ?>">
<input name="dateval1" type="text" class="form-control" disabled>
</div>
<div class="form-group">
<label>Email-ID</label>
<input name="email" type="email" class="form-control" placeholder="Enter Email-ID"
onblur="fun111();" value="<?php echo $email?>">
<input name="emailval" type="text" class="form-control" disabled>
</div>
<div class="form-group">
<label>Password</label>
<input name="password" type="password" class="form-control" placeholder="Enter new password or leave empty for no change"
onblur="fun111();">
<input name="emailval" type="text" class="form-control" disabled>
</div>
<div class="form-group">
<label>Date of Joining</label>
<input name="doj" type="date" class="form-control" placeholder="Enter Date of Joining"
max="<?php echo date("Y-m-d"); ?>" onblur="fun8()" value="<?php echo $doj; ?>">
<input name="dateval" type="text" class="form-control" disabled>
</div>
<div class="form-group">
<label>Address</label>
<textarea name="address" class="form-control" placeholder="Enter Address"
onkeyup="fun11();"> <?php echo $address; ?></textarea>
<input name="addressval" type="text" class="form-control" disabled>
</div>
<div class="form-group">
<label>City</label>
<input name="city" type="text" class="form-control" placeholder="Enter City" onkeyup="fun4();"
value="<?php echo $city; ?>">
<input name="cityval" type="text" class="form-control" disabled>
</div>
<div class="form-group">
<label>State</label>
<input name="state" type="text" class="form-control" placeholder="Enter State" onkeyup="fun5();"
value="<?php echo $state; ?>">
<input name="stateval" type="text" class="form-control" disabled>
</div>
<div class="form-group">
<label>Zip Code</label>
<input name="zip" maxlength="6" type="text" class="form-control" placeholder="Enter Zip Code"
onkeyup="fun6();" value="<?php echo $zipcode; ?>">
<input name="zipval" type="text" class="form-control" disabled>
</div>
<div class="form-group">
<label>Employee Status</label>
<input name="status1" type="text" class="form-control" placeholder="Enter Employee Status"
onkeyup="fun102();" value="<?php echo $emp_status ?>">
<input name="statusval1" type="text" class="form-control" disabled>
</div>
<div class="form-group">
<label>Designation</label>
<input name="designation" type="text" class="form-control" placeholder="Enter Designation"
onkeyup="fun103();" value="<?php echo $designation ?>">
<input name="designationval1" type="text" class="form-control" disabled>
</div>
<div class="form-group">
<label>Employee Status Change</label>
<input name="statuschange" type="text" class="form-control"
placeholder="Enter Employee Status Change"
onkeyup="fun104();" value="<?php echo $emp_status_change ?>">
<input name="statuschangeval" type="text" class="form-control" disabled>
</div>
<!--
Bank Details
-->
<div class="form-group">
<label>Bank Name</label>
<input name="bankname" type="text" class="form-control" placeholder="Enter Bank Name"
onkeyup="fun105();" value="<?php echo $bank_name ?>">
<input name="banknameval" type="text" class="form-control" disabled>
</div>
<div class="form-group">
<label>Account Number</label>
<input name="ac" type="text" class="form-control" placeholder="Enter Account Number"
onkeyup="fun106();" value="<?php echo $bank_accno ?>">
<input name="acval" type="text" class="form-control" disabled>
</div>
<div class="form-group">
<label>Bank Branch</label>
<input name="bbranch" type="text" class="form-control" placeholder="Enter Bank Branch"
onkeyup="fun107();" value="<?php echo $bank_branch ?>">
<input name="bbranchval" type="text" class="form-control" disabled>
</div>
<div class="form-group">
<label>IFSC Code</label>
<input name="ifsc" type="text" class="form-control" placeholder="Enter IFSC Code"
onkeyup="fun108();" value="<?php echo $ifsc ?>">
<input name="ifscval" type="text" class="form-control" disabled>
</div>
<div class="form-group">
<label>MICR Code</label>
<input name="micr" type="text" class="form-control" placeholder="Enter MICR Code"
onkeyup="fun109();" value="<?php echo $micr ?>">
<input name="micrval" type="text" class="form-control" disabled>
</div>
<div class="form-group">
<label>Super Admin</label>
<div class="radio">
<input name="superadmin" type="radio" class="radio" value="1" onclick="fun7()"
<?php $a = ($isSuperadmin == 1) ? 'checked' : ' ';
echo $a; ?>>
 
<label class="radio-inline">Yes</label> 
<input name="superadmin" type="radio" class="radio" value="0" onclick="fun7()"
<?php $a = ($isSuperadmin == 0) ? 'checked' : ' ';
echo $a; ?> > 
<label class="radio-inline">No</label> 
</div>
</div>
<input type="submit" id="sub" class="btn btn-default" value="Update Customer"/>
</form>
</div>
</div>
</main>
<footer class="footer">
<p>© Company 2017</p>
</footer>
</div> <!-- /container -->
</body>
</html>