-
Notifications
You must be signed in to change notification settings - Fork 0
/
tambah.php
47 lines (44 loc) · 1.29 KB
/
tambah.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
<?php
include 'koneksi.php';
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$nama = $_POST['nama'];
$gender = $_POST['jenis_kelamin'];
$kelas = $_POST['kelas'];
$hobi = $_POST['hobi'];
$query = "INSERT INTO siswa (nama, jenis_kelamin, kelas, hobi) VALUES ('$nama', '$gender', '$kelas', '$hobi')";
mysqli_query($koneksi, $query);
header('Location: index.php');
exit();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tambah Data</title>
</head>
<body>
<h2>Tambah Data User</h2>
<form method="POST" action="">
<label>Nama:</label>
<input type="text" name="nama" required>
<br>
<label>Pilih gender:</label>
<select name="jenis_kelamin">
<option value="Laki-laki">Laki-laki</option>
<option value="Perempuan">Perempuan</option>
</select>
<br>
<label>Kelas:</label>
<input type="text" name="kelas" required>
<br>
<label>Hobi:</label>
<input type="text" name="hobi" required>
<br>
<button type="submit">Simpan</button>
</form>
<br>
<a href="index.php">Kembali</a>
</body>
</html>