drzeo

new_produk

Apr 30th, 2015
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.99 KB | None | 0 0
  1. <?php
  2. include "../check.php";
  3. if (!check())
  4. {
  5. echo "<script>alert('Anda tidak berhak mengakses halaman ini')</script>";
  6. echo"Silakan <a href='../login.php'>Login Kembali</a>";
  7. }
  8. else
  9. {?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  10. <html xmlns="http://www.w3.org/1999/xhtml">
  11. <head>
  12. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  13. <title>New Produk</title>
  14. <link rel="stylesheet" href="../style.css" />
  15. <!-- TinyMCE -->
  16. <script type="text/javascript" src="../TINYMCE/JSCRIPTS/TINY_MCE/tiny_mce_src.js"></script>
  17. <script type="text/javascript">
  18.   tinyMCE.init({
  19.     // General options
  20.     mode : "textareas",
  21.     theme : "advanced",
  22.     plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
  23.     // Theme options
  24. theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,cut,copy,paste,pastetext,pasteword,|,search,replace,|",
  25. theme_advanced_buttons2 :
  26. "styleselect,formatselect,fontselect,fontsizeselect,forecolor,backcolor",
  27. theme_advanced_buttons3 : "bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|",
  28.     theme_advanced_toolbar_location : "top",
  29.     theme_advanced_toolbar_align : "left",
  30.     theme_advanced_statusbar_location : "bottom",
  31.     theme_advanced_resizing : true,
  32.     // Example content CSS (should be your site CSS)
  33.     content_css : "css/content.css",
  34.     // Drop lists for link/image/media/template dialogs
  35.     template_external_list_url : "lists/template_list.js",
  36.     external_link_list_url : "lists/link_list.js",
  37.     external_image_list_url : "lists/image_list.js",
  38.     media_external_list_url : "lists/media_list.js",
  39.     // Replace values for the template plugin
  40.     template_replace_values : {
  41.       username : "Some User",
  42.       staffid : "991234"
  43.     }
  44.   });
  45.  
  46.   function convLinkVC(strUrl, node, on_save) {
  47.             strUrl=strUrl.replace("../","");
  48.             return strUrl;
  49.        }
  50.  
  51.   function ajaxLoad() {
  52.   var ed = tinyMCE.get('elm');
  53.  
  54.   // Do you ajax call here, window.setTimeout fakes ajax call
  55.   ed.setProgressState(1); // Show progress
  56.   window.setTimeout(function() {
  57.     ed.setProgressState(0); // Hide progress
  58.     ed.setContent('HTML content that got passed from server.');
  59.   }, 3000);
  60. }
  61.  
  62. function ajaxSave() {
  63.   var ed = tinyMCE.get('elm');
  64.  
  65.   // Do you ajax call here, window.setTimeout fakes ajax call
  66.   ed.setProgressState(1); // Show progress
  67.   window.setTimeout(function() {
  68.     ed.setProgressState(0); // Hide progress        
  69.   }, 3000);
  70. }
  71.  
  72. </script>
  73. <!-- /TinyMCE -->
  74. </head>
  75. <body class="twoColElsLtHdr">
  76.  
  77. <div id="container">
  78.   <div id="header">
  79.     <h1>Panel Admin TokoBuku.com</h1>
  80.   <!-- end #header --></div>
  81.   <div id="sidebar1">
  82.     <div id="main_menu"><h3>Main Menu</h3></div>
  83.   <div id="isi_menu_kiri">
  84.   <a href="../user/index.php">* User Manager</a>
  85.   <a href="../post/index.php">* Menu Post</a>
  86.   <a href="index.php">* Menu Produk</a>
  87.   <a href="../category/index.php">* Menu Category</a>
  88.   <a href="../order/index.php">* Menu Order</a>
  89.   <a href="../bukutamu/index.php">* Menu Buku Tamu</a>
  90.   <a href="../logout.php">* logout</a>
  91.    </div>
  92.   <!-- end #sidebar1 --></div>
  93.   <div id="mainContent">
  94.     <h3> New Product</h3>
  95.     <img src="../images/produk.png" width="51" height="40" /><a href="../category/new_category.php"><img src="../images/ncategory.png" width="153" height="27" /></a><a href="index.php"><img src="../images/vproduk.png" width="136" height="27" /></a>
  96.     <form action="new_produk.php" method="post" name="newproduct" enctype="multipart/form-data">
  97.   <table width="100%" border="0" id="table1">
  98.     <tr>
  99.       <th colspan="2" id="title">Add New Product</th>
  100.     </tr>
  101.     <tr>
  102.       <td id="judul">Code Product</td>
  103.       <td>:
  104.         <input type="text" name="code" maxlength="10" size="85" /></td>
  105.     </tr>
  106.     <tr>
  107.       <td width="140" id="judul">Product name</td>
  108.         <td colspan="2">:
  109.           <input type="text" name="name_product" maxlength="100" size="85" /></td>
  110.     </tr>
  111.     <tr>
  112.         <td id="judul">Description</td>
  113.         <td>:</td></tr>
  114.     <tr>
  115.       <td colspan="2"><textarea name="description" cols="85" rows="5"></textarea></td>
  116.     </tr>
  117.     <tr>
  118.     <td id="judul">Category</td>
  119.         <td>:
  120.           <select name="category">
  121.     <?php
  122.     include"koneksi.php";
  123.     $oke=mysql_query("select * from category order by name_category asc");
  124.     while($data=mysql_fetch_array($oke)){
  125.     echo"<option value='$data[name_category]'>-- $data[name_category] --";
  126.     }
  127.     ?>
  128.     </option></select>
  129.     </td>
  130.       </tr>
  131.     <tr>
  132.       <td id="judul">Price</td>
  133.       <td>:
  134.         <input type="text" name="price" maxlength="10" size="25" /></td>
  135.     </tr>
  136.     <tr>
  137.       <td id="judul">Stock</td>
  138.       <td>
  139.             <label>
  140.               :
  141.               <input type="radio" name="stock" value="ada" id="stock_0" />
  142.               Ada</label>
  143.             &nbsp;&nbsp;&nbsp;&nbsp;
  144.             <label>
  145.               <input type="radio" name="stock" value="kosong" id="stock_1" />
  146.               Kosong</label>
  147.           </td>
  148.     </tr>
  149.     <tr>
  150.       <td id="judul">Status</td>
  151.       <td>
  152.             <label>
  153.               :
  154.               <input type="radio" name="status" value="public" id="status_0" />
  155.               Public</label>
  156.             &nbsp;
  157.             <label>
  158.               <input type="radio" name="status" value="draft" id="status_1" />
  159.               Draft</label>
  160.           </td>
  161.     </tr>
  162.     <tr>
  163.       <td id="judul">Picture</td>
  164.       <td>:
  165.         <input name="picture" type="file" size="25"/></td>
  166.     </tr>
  167.     <tr>
  168.           <td colspan="2"><br /><center>
  169.             <input type="submit" name="simpan" value="Simpan" />
  170.             <input type="reset" name="reset" value="Reset" />
  171.           </center></td>
  172.         </tr>
  173.   </table>
  174.   </form>
  175.   </div>
  176. <br class="clearfloat" />
  177.    <div id="footer">
  178.    <center><p>&copy; Powered 2013 All right reserved</p></center>
  179.   <!-- end #footer --></div>
  180. <!-- end #container --></div>
  181. </body>
  182. </html>
  183.  
  184. <?php
  185. if (isset($_POST['simpan']) !="")
  186. {
  187. //menyimpan gambar keserver//
  188. if ((($_FILES["picture"]["type"]=="image/gif") || ($_FILES["picture"]["type"]=="image/jpeg") || ($_FILES["picture"]["type"]=="image/pjpeg")) && ($_FILES["picture"]["size"]<2000))
  189. {
  190.    if ($_FILES["picture"]["error"] > 0)  
  191.    {
  192.      echo "Return Code:".$_FILES["picture"]["error"]."<br />";
  193.    }  
  194.    else
  195.    {
  196.      echo "Upload:".$_FILES["picture"]["name"]."<br />";
  197.      echo "Type: ".$_FILES["picture"]["type"]."<br />";
  198.      echo "Size: ".($_FILES["picture"]["size"] / 1024)." Kb<br />";
  199.      echo "Temp file: ".$_FILES["picture"]["tmp_name"]."<br />";
  200.      
  201.      if (file_exists("upload/" . $_FILES["picture"]["name"]))
  202.      {
  203.        echo $_FILES["picture"]["name"]."already exists. ";
  204.      }
  205.      else
  206.      {
  207.        move_uploaded_file($_FILES["picture"]["tmp_name"],"upload/" . $_FILES["picture"]["name"]);echo "Stored in: " . "upload/" . $_FILES["picture"]["name"];
  208.      $file_name =$_FILES['picture']['name'];
  209.      }
  210.    }
  211. }
  212. else
  213. {
  214. echo "Invalid file";
  215. }
  216. //simpan kedatabases//
  217. include "db.php";
  218. $code=$_POST['code'];
  219. $name=$_POST['name_product'];
  220. $description=$_POST['description'];
  221. $category=$_POST['category'];
  222. $price=$_POST['price'];
  223. $status=$_POST['status'];
  224. $stock=$_POST['stock'];$data=mysql_query ("INSERT INTO product VALUES ('','$code','$name','$category','$description','$price','$status',now(),'$stock','$file_name','$_SESSION[username]') ") or die (mysql_error());
  225. if ($data){
  226.   echo "<script> alert ('Data Telah Tersimpan'); </script>" ;
  227.   }
  228. else {
  229.   echo "Anda gagal update";
  230. }
  231. }
  232. ?>
  233. <?php } ?>
Advertisement
Add Comment
Please, Sign In to add comment