Guest User

simpanbarang.php

a guest
Oct 27th, 2015
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.20 KB | None | 0 0
  1. <?php
  2. function autono($tabel,$inisial){
  3. $isi=mysql_query("select* from barang order by idbarang desc") or die(mysql_error());
  4. if(mysql_num_rows($isi)==0){
  5. $IDbarang=autono("barang","B$thn");
  6.    
  7.     $idbarang="B$thn"."001";   
  8.     }
  9.     else{
  10.         $data=mysql_fetch_array($isi);
  11.         $bbb=intval(substr($data['idbarang'],3,3))+100001;
  12.         $idbarang="B$thn".substr($bbb,-3);
  13.         }
  14.         return $idbarang;
  15. }
  16. $gambarsmall=$_FILES['uploadsmall']['name'];
  17. $gambarbig=$_FILES['uploadbig']['name'];
  18.  
  19. $simpan=mysql_query("insert into barang (idbarang,namabarang,kategori,spesifikasi,harga,stok,keterangan,gambar) values('$IDbarang','$_POST[namabarang]','$_POST[kategori]','$_POST[spesifikasi]','$_POST[harga]','$_POST[stok]','$_POST[keterangan]','$gambarsmall')") or die(mysql_error());
  20. move_uploaded_file($_FILES['uploadsmall']['tmp_name'],"produk/small/".$gambarsmall);
  21. move_uploaded_file($_FILES['uploadbig']['tmp_name'],"produk/big/".$gambarbig);
  22. if($simpan)
  23. {
  24. ?>
  25.   <script type="text/javascript">
  26.   alert('Data Tersimpan')
  27.   document.location='?page=tampilbarang';
  28.   </script>
  29. <?php
  30.  
  31. }
  32. else
  33. {
  34. ?>
  35.   <script type="text/javascript">
  36.   alert('Gagal Tersimpan')
  37.   document.location='?page=tambahbarang';
  38.   </script>
  39. <?php
  40. }
  41. ?>
Advertisement
Add Comment
Please, Sign In to add comment