-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathform-karyawan.php
110 lines (91 loc) · 4.26 KB
/
form-karyawan.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
104
105
106
107
108
109
110
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Form Karyawan</title>
<link rel="stylesheet" href="css/bootstrap.min.css">
</head>
<body>
<div class="container">
<div class="card">
<div class="card-header bg-dark">
<h4 class="text-white">Form Karyawan</h4>
</div>
<div class="card-body">
<?php
if (isset($_GET["id_karyawan"])) {
# memeriksa ketika load file ini, apakah membawa data GET dengan nama "id_karyawan". jika true, form pelanggan digunakan untuk edit
# mengakses data karyawan dari id_karyawan yang dikirim
include("connection.php");
$id_karyawan = $_GET["id_karyawan"];
$sql = "select * from karyawan where id_karyawan='$id_karyawan'";
# eksekusi perintah sql
$ubah = mysqli_query($connect, $sql);
# konversi hasil query ke bentuk array
$karyawan = mysqli_fetch_array($ubah);
?>
<form action="process-karyawan.php" method="post"
onsubmit="return confirm('Apakah anda benar ingin mengedit data ini?')">
ID karyawan
<input type="text" name="id_karyawan"
class="form-control mb-2" required
value="<?=$karyawan["id_karyawan"];?>" readonly>
Nama karyawan
<input type="text" name="nama_karyawan"
class="form-control mb-2" required
value="<?=$karyawan["nama_karyawan"];?>">
Alamat
<input type="text" name="alamat_karyawan"
class="form-control mb-2" required
value="<?=$karyawan["alamat_karyawan"];?>">
Kontak
<input type="text" name="kontak"
class="form-control mb-2" required
value="<?=$karyawan["kontak"];?>">
Username
<input type="text" name="username"
class="form-control mb-2" required
value="<?=$karyawan["username"];?>">
Password
<input type="password" name="password"
class="form-control mb-2">
<button type="submit" class="btn btn-success btn-block"
name="edit_karyawan">
Save
</button>
</form>
<?php
}else{
# jika false, menggunakan ini untuk insert
?>
<form action="process-karyawan.php" method="post">
Nama karyawan
<input type="text" name="nama_karyawan"
class="form-control mb-2" required>
Alamat
<input type="text" name="alamat_karyawan"
class="form-control mb-2" required>
Kontak
<input type="text" name="kontak"
class="form-control mb-2" required>
Username
<input type="text" name="username"
class="form-control mb-2" required>
Password
<input type="password" name="password"
class="form-control mb-2" required>
<button type="submit" class="btn btn-success btn-block"
name="simpan_karyawan">
Save
</button>
</form>
<?php
}
?>
</div>
</div>
</div>
</body>
</html>