-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
profile.php
103 lines (97 loc) · 3.87 KB
/
profile.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
<?php
include_once 'header.php';
include_once 'includes/user.inc.php';
$eks = new User($db);
$eks->id = intval($_SESSION['id_pengguna']);
$eks->readOne();
if($_POST){
if (isset($_POST['rl'])) {
$eks->rl = addslashes($_POST['rl']);
} else {
$eks->rl = 'User';
}
$eks->nl = addslashes($_POST['nl']);
$eks->mail = addslashes($_POST['mail']);
$eks->un = addslashes($_POST['un']);
$eks->pw = md5(addslashes($_POST['pw']));
if ($_SESSION['id_pengguna'] != 1 OR $_SESSION['id_pengguna'] != "1") {
if($eks->update()){
$_SESSION['nama_lengkap'] = addslashes($_POST['nl']);
?>
<div class="alert alert-success alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Berhasil!</strong> Anda telah mengubah profile sendiri.
</div>
<?php
} else {
?>
<div class="alert alert-danger alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Gagal Ubah profile!</strong> Terjadi kesalahan, coba sekali lagi.
</div>
<?php
}
} else {
if($eks->update('fpengguna')){
$_SESSION['nama_lengkap'] = addslashes($_POST['nl']);
?>
<div class="alert alert-success alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Berhasil!</strong> Anda telah mengubah profile sendiri.
</div>
<?php
} else {
?>
<div class="alert alert-danger alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Gagal Ubah profile!</strong> Terjadi kesalahan, coba sekali lagi.
</div>
<?php
}
}
}
?>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-8">
<div class="page-header">
<h5>Profile Anda</h5>
</div>
<form method="post">
<div class="form-group">
<label for="nl">Nama Lengkap</label>
<input type="text" class="form-control" id="nl" name="nl" value="<?php echo $eks->nl; ?>" required>
</div>
<div class="form-group">
<label for="mail">Email</label>
<input type="email" class="form-control" id="mail" name="mail" value="<?php echo $eks->mail; ?>" required>
</div>
<div class="form-group">
<label for="un">Username</label>
<input type="text" class="form-control" id="un" name="un" value="<?php echo $eks->un; ?>" readonly required>
</div>
<div class="form-group">
<label for="pw">Password</label>
<input type="password" class="form-control" id="pw" name="pw" placeholder="Masukkan password Anda ..." required>
</div>
<?php if (isset($_SESSION['role'])) {
if ($_SESSION['role'] === base64_encode('Admin')) { ?>
<div class="form-group">
<label for="up">Role</label>
<select name="rl" class="form-control" id="up">
<option>-- Pilih --</option>
<option value="Admin">Admin</option>
<option value="User">User</option>
</select>
</div>
<?php }
} ?>
<button type="submit" class="btn btn-primary">Ubah</button>
</form>
</div>
<div class="col-xs-12 col-sm-12 col-md-4">
<?php include_once 'sidebar.php'; ?>
</div>
</div>
<?php
include_once 'footer.php';
?>