-
Notifications
You must be signed in to change notification settings - Fork 0
/
profil.php
70 lines (64 loc) · 2.01 KB
/
profil.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
<?php
//berkas sistem
require_once './app/config.php';
require_once './app/database.php';
require_once './app/fungsi.php';
//fungsi-fungsi
_isLogin();
$error = 0;
$username = $_SESSION['username'];
$profil = db_petugas_get_data_by_username($db_conn, $username);
$ubah = filter_input(INPUT_POST, 'ubah', FILTER_SANITIZE_STRING);
if (!empty($ubah)) {
$nama = filter_input(INPUT_POST, 'nama', FILTER_SANITIZE_STRING);
$password = filter_input(INPUT_POST, 'password', FILTER_SANITIZE_STRIPPED);
$ubah = db_petugas_update($db_conn, $username, $nama, $password);
if ($ubah > 0) {
//kembali ke menu utama
$_SESSION['nama'] = $nama;
header('Location: index.php');
} else {
$error = 1;
}
}
?>
<html>
<head>
<title>Profil</title>
</head>
<body>
<p><a href="./index.php">Home</a> > Profil</p>
<form action="./profil.php" method="post">
<table>
<tr>
<td>Username</td>
<td>:</td>
<td><?= $profil['username'] ?></td>
</tr>
<tr>
<td>Nama Pengguna</td>
<td>:</td>
<td><input type="text" name="nama" value="<?= $profil['nama'] ?>" required></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input type="password" name="password"></td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<input type="submit" name="ubah" value="UBAH">
</td>
</tr>
</table>
</form>
<p>Catatan : Kosongkan Kolom Password Jika Tidak Ingin Di Rubah Datanya</p>
<?php
if ($error == 1) :
echo '<p>Tidak ada data yang dirubah, pastikan ada perubahan pada Nama atau Password sebelumnya.</p>';
endif;
?>
</body>
</html>