0% found this document useful (0 votes)
7 views7 pages

Proses Crud

The document outlines the process of creating a cash register application with a focus on CRUD operations for products. It includes instructions for setting up files such as 'proses.php' and 'tambah_produk.php', as well as the necessary HTML and PHP code for adding and deleting products. Additionally, it emphasizes the importance of connecting to a database and handling form submissions for product management.

Uploaded by

tiengcity
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views7 pages

Proses Crud

The document outlines the process of creating a cash register application with a focus on CRUD operations for products. It includes instructions for setting up files such as 'proses.php' and 'tambah_produk.php', as well as the necessary HTML and PHP code for adding and deleting products. Additionally, it emphasizes the importance of connecting to a database and handling form submissions for product management.

Uploaded by

tiengcity
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

APLIKASI KASIR

MODUL 7

PROSES CRUD PRODUK


TAMPILAN TAMBAH PRODUK
1. buat file baru dengan nama proses.php -> nantinya semua proses crud akan
disimpan di file ini
2. buka file produk.php, tambahkan syntax dibawah : (jika sudah ada maka biarkan
saja )

3. buat file baru dengan nama tambah_produk.php, syntaxnya yaitu:


<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Aplikasi Kasir</title>

<!-- Google Font: Source Sans Pro -->


<link rel="stylesheet" href="https://fonts.googleapis.com/css?
family=Source+Sans+Pro:300,400,400i,700&display=fallback">
<!-- Font Awesome -->
<link rel="stylesheet"
href="assets/plugins/fontawesome-free/css/all.min.css">
<!-- Theme style -->
<link rel="stylesheet" href="assets/dist/css/adminlte.min.css">
</head>

<body class="hold-transition sidebar-mini">


<!-- Site wrapper -->
<div class="wrapper">
<?php
require_once("tampilan/navbar.php");
?>

<?php
require_once("tampilan/sidebar.php");
?>

<!-- Content Wrapper. Contains page content -->


<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<div class="container-fluid">

</div><!-- /.container-fluid -->


</section>

<!-- Main content -->


<section class="content">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="card card-primary">
<div class="card-header">
<h3 class="card-title">Tambah
Produk</h3>
</div>
<form action="proses.php?action=tambah"
method="POST">
<div class="card-body">
<div class="form-group">
<label for="kode_barang">Kode
Barang</label>
<input type="text"
class="form-control" id="kode_barang" name="kode_barang">
</div>
<div class="form-group">
<label for="nama_barang">Nama
Barang</label>
<input type="text"
class="form-control" id="nama_barang" name="nama_barang">
</div>
<div class="form-group">
<label
for="harga">Harga</label>
<input type="number"
class="form-control" id="harga" name="harga">
</div>
<div class="form-group">
<label for="stok">Stok
Barang</label>
<input type="number"
class="form-control" id="stok" name="stok">
</div>
<div class="form-group">
<label
for="satuan">Satuan</label>
<input type="text"
class="form-control" id="satuan" name="satuan">
</div>

<div class="card-footer">
<button type="submit"
class="btn btn-primary">Simpan</button>
<button class="btn btn-
warning"><a href="produk.php">Kembali</a></button>
</div>
</form>
</div>

</section>
<!-- /.content -->
</div>
<!-- /.content-wrapper -->

<?php
require_once("tampilan/footer.php");
?>

</div>
<!-- ./wrapper -->

<!-- jQuery -->


<script src="assets/plugins/jquery/jquery.min.js"></script>
<!-- Bootstrap 4 -->
<script
src="assets/plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- AdminLTE App -->
<script src="assets/dist/js/adminlte.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="assets/dist/js/demo.js"></script>
</body>

</html>

PROSES TAMBAH PRODUK


4. pastikan ada action berikut pada tampilan tambah_produk :

5. buka file proses.php


tambahkan syntax berikut :
<?php
include "koneksi.php";
session_start();

$action = $_GET['action'];
//crud produk
if ($action == "tambah") {
$kode = $_POST['kode_barang'];
$nama = $_POST['nama_barang'];
$harga = $_POST['harga'];
$stok = $_POST['stok'];
$satuan = $_POST['satuan'];

$data = mysqli_query($koneksi, "insert into produk values


('$kode','$nama','$harga','$stok','$satuan')");
header("location:produk.php");
}
PROSES HAPUS PRODUK
1. pastikan sudah ada syntax berikut pada produk.php

2. buka kembali proses.php, tambahkan syntax berikut dibawah syntax tambah produk

elseif ($action == "delete") {


$kode_produk = $_GET['kode_produk'];
$data = mysqli_query($koneksi, "delete from produk where
kode_produk='$kode_produk'");
header("location:produk.php");
}

You might also like