cahyadsn

edit barang

Jun 19th, 2020
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.54 KB | None | 0 0
  1. <?php
  2. include_once("koneksi.php");
  3. if(isset($_POST['update'])){
  4.     $Kode_Brg   = $_POST['Kode_Brg'];
  5.     $Deskripsi  = $_POST['Deskripsi'];
  6.     $Harga      = $_POST['Harga'];
  7.     $Disc       = $_POST['Disc'];
  8.     $Qty        = $_POST['Qty'];
  9.     $Sub_Total  = $_POST['Sub_Total'];
  10.     $No_Nota    = $_POST['No_Nota'];
  11.     if(empty($Deskripsi) || empty($Harga) || empty($Qty) || empty($Sub_Total) || empty($No_Nota)) {
  12.         if(empty($Deskripsi)) {
  13.             echo "<font color='red'>Deskripsi tidak boleh kosong.</font><br/>";
  14.         }
  15.         if(empty($Harga)) {
  16.             echo "<font color='red'>Harga tidak boleh kosong.</font><br/>";
  17.         }
  18.         if(empty($Qty)) {
  19.             echo "<font color='red'>Kwantitas tidak boleh kosong.</font><br/>";
  20.         }
  21.         if(empty($Sub_Total)) {
  22.             echo "<font color='red'>Sub-Total tidak boleh kosong.</font><br/>";
  23.         }
  24.         if(empty($No_Nota)) {
  25.             echo "<font color='red'>No. Nota tidak boleh kosong.</font><br/>";
  26.         }
  27.     } else {
  28.         $sql="UPDATE barang
  29.              SET
  30.                Deskripsi='{$Deskripsi}',
  31.                Harga='{$Harga}',
  32.                Disc='{$Disc}',
  33.                Qty='{$Qty}',
  34.                Sub_Total='{$Sub_Total}',
  35.                No_Nota='{$No_Nota}'
  36.              WHERE
  37.                Kode_Brg='{$Kode_Brg}'";
  38.         $result = mysqli_query($link,$sql) or die($sql);
  39.         header("Location: index_barang.php");
  40.     }
  41. }
  42. $Kode_Brg = $_GET['Kode_Brg'];
  43. $result = mysqli_query($link,"SELECT * FROM barang WHERE Kode_Brg='{$Kode_Brg}'");
  44. $res    = mysqli_fetch_array($result));
  45. $Kode_Brg   = $res['Kode_Brg'];
  46. $Deskripsi  = $res['Deskripsi'];
  47. $Harga      = $res['Harga'];
  48. $Disc       = $res['Disc'];
  49. $Qty        = $res['Qty'];
  50. $Sub_Total  = $res['Sub_Total'];
  51. $No_Nota    = $res['No_Nota'];
  52. ?>
  53. <html>
  54. <head>
  55.     <title> Data Nota dan Barang </title>
  56.     <link rel="stylesheet" type="text/css" href="container.css">
  57.   </head>
  58.   <body>
  59.     <h1><span class="blue"></span>Edit<span class="blue"></span>
  60.         <span class="yellow">Data Barang</pan></h1>
  61.     <h2>Created with love by <a href="www.yusufrhamadan.com" target="_blank">Yusuf Rhamadan</a></h2>
  62.     <a href="index_barang.php" class="btInIsmynr1">Kembali</a>
  63.     <br/><br/>
  64.     <form name="form1" method="post" action="edit_barang.php">
  65.         <table class="container" border="0">
  66.             <tr>
  67.                 <td>Deskripsi</td>
  68.                 <td><input type="text" name="Deskripsi" value="<?php echo $Deskripsi;?>"></td>
  69.             </tr>
  70.             <tr>
  71.                 <td>Harga</td>
  72.                 <td><input type="text" name="Harga" value="<?php echo $Harga;?>"></td>
  73.             </tr>
  74.             <tr>
  75.                 <td>Discount</td>
  76.                 <td><input type="text" name="Disc" value="<?php echo $Disc;?>"></td>
  77.             </tr>
  78.             <tr>
  79.                 <td>Kwantitas</td>
  80.                 <td><input type="text" name="Qty" value="<?php echo $Qty;?>"></td>
  81.             </tr>
  82.             <tr>
  83.                 <td>Sub-Total</td>
  84.                 <td><input type="text" name="Sub_Total" value="<?php echo $Sub_Total;?>"></td>
  85.             </tr>
  86.             <tr>
  87.                 <td>No. Nota</td>
  88.                 <td><input type="text" name="No_Nota" value="<?php echo $No_Nota;?>"></td>
  89.             </tr>
  90.             <tr>
  91.                 <td><input type="hidden" name="Kode_Brg" value=<?php echo $Kode_Brg;?>></td>
  92.                 <td><input type="submit" name="update" value="Update"></td>
  93.             </tr>
  94.         </table>
  95.     </form>
  96. </body>
  97. </html>
Add Comment
Please, Sign In to add comment