----------------------------------------------------------------------------------------------------
index.php
<!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">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/bootstrap.css">
<script src="js/bootstrap.bundle.js"></script>
<title>Praktek 2</title>
</head>
<body>
<div class="m-5 w-10 vh-100 align-content-center justify-content-center d-flex top-50 bg-dark text-bg-dark" >
<form method="post" action="tampilan.php">
<label> Nama : </label>
<input type="text" name="nama" class="input-group-text"><br><br>
<label> kelas : </label>
<!-- <input type="radio" value="Pria" name="jeniskel">Pria
<input type="radio" value="Wanita" name="jeniskel">Wanita -->
<select name="kelas" class="btn btn-primary">
<option value="X">X</option>
<option value="XI">XI</option>
<option value="XII">XII</option>
</select><br><br>
<input type="submit" value="kirim" name="proses" class="btn btn-success">
<input type="reset" value="reset" class="btn btn-warning">
<a href="" class="btn btn-info">Tampil Data</a>
</div>
</form>
</body>
</html>
----------------------------------------------------------------------------------------------------
koneksi.php
<?php
$conn = mysqli_connect("localhost", "root", "", "praktek2");
?>
----------------------------------------------------------------------------------------------------
tampilan.php
<?php
include "koneksi.php";
if (isset($_POST['proses'])) {
mysqli_query($conn, "insert into data_2 set
NAMA = '$_POST[nama]',
kelas = '$_POST[kelas]'");
echo "<div class='bg-success text-white p-3'><h6>Data berhasil disimpan</h6></div>";
}
?>
<!DOCTYPE html>
<html>
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/bootstrap.css">
<script src="js/bootstrap.bundle.js"></script>
<head>
<title></title>
</head>
<body>
<div style="overflow-x:auto;" class="m-5 rounded">
<h1> TAMPILKAN DATA </h1>
<table class="table table-dark table-hover table-striped-columns text-center justify-content-center align-content-center rounded">
<tr>
<th>ID</th>
<th>NAMA</th>
<th>Kelas</th>
</tr>
<?php
include 'koneksi.php';
$tampil = mysqli_query($conn, "SELECT * FROM data_2");
foreach ($tampil as $data) {
?>
<tr>
<td><?php echo $data["id"]; ?></td>
<td><?php echo $data["nama"]; ?></td>
<td><?php echo $data["kelas"]; ?></td>
</tr>
<?php
}
?>
</table>
<a href="Index.php" class="btn btn-primary">Tambah Data</a>
</div>
</body>
</html>
----------------------------------------------------------------------------------------------------
Hasil :