Pertama yang harus dibuat adalah halaman form_distribusi.php, dimana halaman ini menampilkan form inputan yang ketika tombol simpan di tekan akan membuka halaman simpan_distribusi.php yang berfungsi untuk memproses penyimpanan data ke database.
form_distribusi.php
<html><head><title>TOKO BUKU - DISTRIBUTOR</title></head><body>
<form action="simpan_distributor.php" method="post">
<table>
<tr>
<th colspan="3" align="center">INPUT DISTRIBUTOR</th>
</tr>
<tr>
<td>NAMA DISTRIBUTOR</td>
<td>:</td>
<td><input type="text" name="nama_distributor" size="30"></td>
</tr>
<tr>
<td>ALAMAT</td>
<td>:</td>
<td><input type="text" name="alamat" size="30"></td>
</tr>
<tr>
<td>TELEPON</td>
<td>:</td>
<td><input type="text" name="telepon" size="15"></td>
</tr>
<tr>
<td></td><td></td>
<td><input type="submit" value="SIMPAN">
<input type="reset" value="RESET">
</td>
</tr>
</table>
</form>
<body></html>
simpan_distribusi.php
<html><head><title>BUKU TAMU</title></head><body>
<?php
$koneksi = mysqli_connect('localhost','root','','tokobuku');
$nama_distributor = $_POST['nama_distributor'];
$alamat = $_POST['alamat'];
$telepon = $_POST['telepon'];
$simpan_distributor = mysqli_query($koneksi, "INSERT INTO distributor (nama_distributor,alamat,telepon)
VALUES ('$nama_distributor','$alamat','$telepon')");
if ($simpan_distributor){
echo"<br><br><br><center>";
echo"<p style='font-weight:600; font-size:50px; color:red'>Distributor Telah Berhasil di Simpan</p>";
echo"</center>";
}else{
echo"<br><br><br><center>Distributor Gagal di Simpan</center>";
}
echo"<center><a href='form_distributor.php'> <<-- Kembali</center></a>";
?>
</body></html>
No comments:
Post a Comment