barang-edit.php

mail@pastecode.io avatar
unknown
php
2 years ago
1.3 kB
25
Indexable
Never
<?php
include "koneksi.php";
$sql=mysqli_query($koneksi,"select * from barang where kode_barang='$_GET[kode]'");
$data=mysqli_fetch_array($sql);

?>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Tambah Barang</title>
</head>
<body>
	<h3> Tambah Barang </h3>

<form action="" method="post">
	<p><a href="data-barang.php">Data Barang</a></p>
	<table>
		<tr>
			<td width="130">Kode Barang</td>
			<td><input type="text" name="kode_barang" value="<?php echo $data['kode_barang']; ?>"> </td>
		</tr>
		<tr>
			<td>Nama Baranng</td>
			<td><input type="text" name="nama_barang" value="<?php echo $data['nama_barang']; ?>"> </td>
		</tr>
		<tr>
			<td>Harga Barang</td>
			<td><input type="text" name="harga_barang" value="<?php echo $data['harga_barang']; ?>"></td>
		</tr>
		<tr>
			<td></td>
			<td><input type="submit" value="simpan" name="proses"></td>
		</tr>
	</table>
</form>

<?php 
include "koneksi.php";

if(isset($_POST['proses'])){
	mysqli_query($koneksi, "insert into barang set
	kode_barang = '$_POST[kode_barang]',
	nama_barang = '$_POST[nama_barang]',
	harga_barang = '$_POST[harga_barang]'");

	echo "Data barang baru telah tersimpan";
}
?>
</body>
</html>