-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdo_input.php
More file actions
27 lines (23 loc) · 775 Bytes
/
do_input.php
File metadata and controls
27 lines (23 loc) · 775 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
include "koneksi.php";
$nama = $_POST['nama'];
$ket = $_POST['ket'];
$stock = $_POST['stock'];
$harga = $_POST['harga'];
$query = "select max(kd_produk) as maxkode from produk";
$hasil = mysqli_query($conn, $query);
$data = mysqli_fetch_array($hasil);
$kode = $data['maxkode'];
$ubah = (int) substr($kode, 4, 3);
$ubah++;
$kd_produk = "PRK-" . sprintf("%03s", $ubah);
$query1 = "insert into produk (keterangan, jumlah, harga, nama_produk, kd_produk) values ('$ket', '$stock', '$harga', '$nama', '$kd_produk')";
$sql = mysqli_query($conn, $query1);
if(mysqli_affected_rows($conn) >= 0)
{
echo "1";
}
else
{
echo "0";
}