Entry Data Barang
Kode Program ;<html>
<head><title>Entry Data</title></head>
<body>
<h2>Entry Data Barang</h2>
<form action="<? echo $PHP_SELF; ?>" method=post>
Kode Brg <input type=text name="kodebrg"><br>
Nama Brg <input type=text name="namabrg"><br>
Satuan<input type=text name="satuan"><br>
Harga(Rp)<input type=text name="harga"><br>
<input type=submit name="aksi" value="Save">
<input type=reset value="Reset">
<br><br>
<a href=browse.php>Lihat Daftar Barang</a>
</form>
<?
if (isset($kodebrg) && isset($namabrg) && isset
($aksi)){
echo "Konfirmasi:<br>";
$conn=mysql_connect("localhost","root","");
mysql_select_db("dbjual",$conn);
$sql="INSERT INTO barang
(kodebrg,namabrg,satuan,harga)
VALUES
('$kodebrg','$namabrg','$satuan','$harga') ";
mysql_query($sql,$conn);
if (mysql_affected_rows())
echo "Proses input data record telah
berhasil!";
else
echo "Proses input data record gagal!";
}
?>
</body>
</html>
Struktur Database;
-- phpMyAdmin SQL Dump
-- version 3.1.3.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Mar 20, 2014 at 09:14 AM
-- Server version: 5.1.33
-- PHP Version: 5.2.9
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
--
-- Database: `dbjual`
--
-- --------------------------------------------------------
--
-- Table structure for table `barang`
--
CREATE TABLE IF NOT EXISTS `barang` (
`kodebrg` char(5) NOT NULL,
`namabrg` varchar(35) NOT NULL,
`satuan` char(3) NOT NULL,
`harga` double NOT NULL,
PRIMARY KEY (`kodebrg`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Dumping data for table `barang`
--
INSERT INTO `barang` (`kodebrg`, `namabrg`, `satuan`, `harga`) VALUES
('C0001', 'Foridina', 'box', 36000),
('C002', 'Susu Kedelai', 'BOX', 20000);
Post a Comment