Pastikan sudah menyiapkan:
http://localhosthtdocs.pendaftaranBuka http://localhost/phpmyadmin → buat database: db_pendaftaran → lalu buat tabel:
id INT AUTO_INCREMENT PRIMARY KEY
no_daftar VARCHAR(10)
nama VARCHAR(100)
jk ENUM('Laki-laki','Perempuan')
asal_sekolah VARCHAR(100)
no_hp VARCHAR(15)
pendaftaran/ │── config.php │── index.php │── tambah.php │── edit.php │── hapus.php
<?php
$host = "localhost";
$user = "root";
$pass = "";
$db = "db_pendaftaran";
$koneksi = mysqli_connect($host, $user, $pass, $db);
if (!$koneksi) {
die("Koneksi gagal: " . mysqli_connect_error());
}
?>
<?php include 'config.php'; ?> <center> <h2>Data Pendaftaran Siswa Baru</h2> <a href="tambah.php">+ Tambah Data</a> ... </center>
<?php include 'config.php'; ?>
<center>
<h2>Tambah Data Siswa</h2>
<form method="POST">
...
</form>
</center>
<?php include 'config.php'; ?>
<center>
<h2>Edit Data Siswa</h2>
<form method="POST">
...
</form>
</center>
<?php
include 'config.php';
$id = $_GET['id'];
mysqli_query($koneksi, "DELETE FROM siswa WHERE id=$id");
header("Location: index.php");
?>
http://localhost/pendaftaran