-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate.php
More file actions
57 lines (45 loc) · 1.09 KB
/
create.php
File metadata and controls
57 lines (45 loc) · 1.09 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
<?php
include "config.php";
// Jika tombol button diklik, maka kita perlu memproses form nya
if (isset($_POST['submit'])) {
// Ambil variables dari the form
$nama = $_POST['nama'];
$gaji = $_POST['gaji'];
$kota = $_POST['kota'];
$deskripsi = $_POST['deskripsi'];
//Tulis sql query
$sql = "INSERT INTO `pegawai`(`nama`, `gaji`, `kota`, `deskripsi`) VALUES ('$nama', '$gaji', '$kota', '$deskripsi')";
//Eksekusi query
$result = $conn->query($sql);
if ($result == TRUE) {
echo "New record created successfully.";
}else{
echo "Error:". $sql . "<br>". $conn->error;
}
$conn->close();
}
?>
<!DOCTYPE html>
<html>
<body>
<h2>Form Pendaftaran</h2>
<form action="" method="POST">
<fieldset>
<legend>Personal information:</legend>
Nama:<br>
<input type="text" name="nama">
<br>
Gaji:<br>
<input type="float" name="gaji">
<br>
Kota:<br>
<input type="text" name="kota">
<br>
Deskripsi:<br>
<input type="text" name="deskripsi">
<br><br>
<input type="submit" name="submit" value="submit">
</fieldset>
</form>
</body>
</html>