untuk membuat Form Toko Buku berbasis web dapat dilakukan dengan bebera langkah sebagai berikut:
1. MEMBUAT FORM BUKU
<html>
<head>
<title>Input Buku</title>
</head>
<body>
<h1 align="Tambah Data Buku">
<form action="simpan_buku.php" method="POST">
<table>
<tr>
<html>
<head>
<title>Input Buku</title>
</head>
<body>
<h1 align="Tambah Data Buku">
<form action="simpan_buku.php" method="POST">
<table>
<tr>
<td>Kode Buku</td>
<td>:</td>
<td><input type="textfield" name="kode"></td>
</tr>
<tr>
<td>Nama Buku</td>
<td>:</td>
<td><input type="textfield" name="nama"></td>
</tr>
<tr>
<td>Harga</td>
<td>:</td>
<td><input type="textfield" name="harga"></td>
</tr>
<tr>
<td>Resensi</td>
<td>:</td>
<td><input type="textfield" name="resensi"></td>
</tr>
<tr>
<td>Bonus</td>
<td>:</td>
<td>
<select name="bonus">
<option value="CD Tutorial">CD Tutorial</option>
<option value="Penggaris">Penggaris</option>
<option value="Pensil">Pensil</option>
</select>
</td>
</tr>
<tr>
<td>Keterangan</td>
<td>:</td>
<td>
<select name="keterangan">
<option value="Hot Sale">Hot Sale</option>
<option value="New">New</option>
</select>
</td>
</tr>
<tr>
<td><input type="submit" value="simpan"></td>
<td></td>
<td><input type="reset" value="reset"></td>
</tr>
</table>
</form>
</body>
</html>
<td>:</td>
<td><input type="textfield" name="kode"></td>
</tr>
<tr>
<td>Nama Buku</td>
<td>:</td>
<td><input type="textfield" name="nama"></td>
</tr>
<tr>
<td>Harga</td>
<td>:</td>
<td><input type="textfield" name="harga"></td>
</tr>
<tr>
<td>Resensi</td>
<td>:</td>
<td><input type="textfield" name="resensi"></td>
</tr>
<tr>
<td>Bonus</td>
<td>:</td>
<td>
<select name="bonus">
<option value="CD Tutorial">CD Tutorial</option>
<option value="Penggaris">Penggaris</option>
<option value="Pensil">Pensil</option>
</select>
</td>
</tr>
<tr>
<td>Keterangan</td>
<td>:</td>
<td>
<select name="keterangan">
<option value="Hot Sale">Hot Sale</option>
<option value="New">New</option>
</select>
</td>
</tr>
<tr>
<td><input type="submit" value="simpan"></td>
<td></td>
<td><input type="reset" value="reset"></td>
</tr>
</table>
</form>
</body>
</html>
2. KONEKSI
<?php
$host = "localhost";
$user = "root";
$pass = "";
$db = "toko_buku";
$koneksi = mysql_connect($host, $user, $pass);
$database = mysql_select_db($db, $koneksi);
if($database){
}
?>
3. SIMPAN BUKU
<?php
<?php
include "koneksi.php";
$kode = $_POST['kode'];
$nama = $_POST['nama'];
$harga = $_POST['harga'];
$resensi = $_POST['resensi'];
$bonus = $_POST['bonus'];
$keterangan = $_POST['keterangan'];
$query = mysql_query("insert into buku(kode, nama, harga, resensi, bonus, keterangan) values('$kode', '$nama', '$harga', '$resensi', '$bonus', '$keterangan')");
if($query){
echo "Sukses";
$kode = $_POST['kode'];
$nama = $_POST['nama'];
$harga = $_POST['harga'];
$resensi = $_POST['resensi'];
$bonus = $_POST['bonus'];
$keterangan = $_POST['keterangan'];
$query = mysql_query("insert into buku(kode, nama, harga, resensi, bonus, keterangan) values('$kode', '$nama', '$harga', '$resensi', '$bonus', '$keterangan')");
if($query){
echo "Sukses";
}
?>
?>
Tidak ada komentar:
Posting Komentar