-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdateuser.php
72 lines (68 loc) · 2.29 KB
/
updateuser.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
<?php
require_once 'config/config.php';
if (isset($_GET['user_id'])) {
$user = getUserById($_GET['user_id']);
}else {
if (isset($_POST['id'],$_POST['username'],$_POST['full_name'],$_POST['email'],$_POST['password'],$_POST['re-password'])) {
$id = $_POST['id'];
$username = $_POST['username'];
$full_name = $_POST['full_name'];
$email = $_POST['email'];
$password = $_POST['password'];
$re_password = $_POST['re-password'];
$type = STUDENTS;
updateUser($id, $username, $full_name, $email, $password, $type);
$user = getUserById($_POST['id']);
?>
<script type="text/javascript">
var full_name = "<?php echo $full_name; ?>";
alert("successfully updated" + " " + full_name);
window.location.href = "index.php";
</script>
<?php
}else {
header("location:404.php");
exit();
}
}
_header(APP_NAME);
?>
<div class="row">
<div class="col-12">
<a href="index.php" class="h4 page-link bg-primary text-white text-center text-uppercase font-weight-bold">All Students</a>
</div>
</div>
<div class="row justify-content-center">
<div class="col-6">
<form class="form form-control" action="updateuser.php" method="post">
<div class="form-text bg-success text-white text-center font-weight-bold rounded">Update User</div>
<div class="form-group">
<input type="hidden" name="id" class="form-control" value="<?php echo $user['id'] ?>">
</div>
<div class="form-group">
<label>Full Name</label>
<input type="text" name="full_name" class="form-control" value="<?php echo $user['full_name']?>">
</div>
<div class="form-group">
<label>Username</label>
<input type="text" name="username" class="form-control" value="<?php echo $user['username']?>">
</div>
<div class="form-group">
<label>Email</label>
<input type="email" name="email" class="form-control" value="<?php echo $user['email']?>">
</div>
<div class="form-group">
<label>Password</label>
<input type="password" name="password" class="form-control" value="">
</div>
<div class="form-group">
<label>Re-enter Password</label>
<input type="password" name="re-password" class="form-control" value="">
</div>
<div class="form-group">
<button class="btn btn-success btn-block font-weight-bold" type="submit">Save</button>
</div>
</form>
</div>
</div>
<?php _footer(); ?>