Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include "../check.php";
- if (!check())
- {
- echo "<script>alert('Anda tidak berhak mengakses halaman ini')</script>";
- echo"Silakan <a href='../login.php'>Login Kembali</a>";
- }
- else
- {?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>New Produk</title>
- <link rel="stylesheet" href="../style.css" />
- <!-- TinyMCE -->
- <script type="text/javascript" src="../TINYMCE/JSCRIPTS/TINY_MCE/tiny_mce_src.js"></script>
- <script type="text/javascript">
- tinyMCE.init({
- // General options
- mode : "textareas",
- theme : "advanced",
- 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",
- // Theme options
- theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,cut,copy,paste,pastetext,pasteword,|,search,replace,|",
- theme_advanced_buttons2 :
- "styleselect,formatselect,fontselect,fontsizeselect,forecolor,backcolor",
- theme_advanced_buttons3 : "bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|",
- theme_advanced_toolbar_location : "top",
- theme_advanced_toolbar_align : "left",
- theme_advanced_statusbar_location : "bottom",
- theme_advanced_resizing : true,
- // Example content CSS (should be your site CSS)
- content_css : "css/content.css",
- // Drop lists for link/image/media/template dialogs
- template_external_list_url : "lists/template_list.js",
- external_link_list_url : "lists/link_list.js",
- external_image_list_url : "lists/image_list.js",
- media_external_list_url : "lists/media_list.js",
- // Replace values for the template plugin
- template_replace_values : {
- username : "Some User",
- staffid : "991234"
- }
- });
- function convLinkVC(strUrl, node, on_save) {
- strUrl=strUrl.replace("../","");
- return strUrl;
- }
- function ajaxLoad() {
- var ed = tinyMCE.get('elm');
- // Do you ajax call here, window.setTimeout fakes ajax call
- ed.setProgressState(1); // Show progress
- window.setTimeout(function() {
- ed.setProgressState(0); // Hide progress
- ed.setContent('HTML content that got passed from server.');
- }, 3000);
- }
- function ajaxSave() {
- var ed = tinyMCE.get('elm');
- // Do you ajax call here, window.setTimeout fakes ajax call
- ed.setProgressState(1); // Show progress
- window.setTimeout(function() {
- ed.setProgressState(0); // Hide progress
- }, 3000);
- }
- </script>
- <!-- /TinyMCE -->
- </head>
- <body class="twoColElsLtHdr">
- <div id="container">
- <div id="header">
- <h1>Panel Admin TokoBuku.com</h1>
- <!-- end #header --></div>
- <div id="sidebar1">
- <div id="main_menu"><h3>Main Menu</h3></div>
- <div id="isi_menu_kiri">
- <a href="../user/index.php">* User Manager</a>
- <a href="../post/index.php">* Menu Post</a>
- <a href="index.php">* Menu Produk</a>
- <a href="../category/index.php">* Menu Category</a>
- <a href="../order/index.php">* Menu Order</a>
- <a href="../bukutamu/index.php">* Menu Buku Tamu</a>
- <a href="../logout.php">* logout</a>
- </div>
- <!-- end #sidebar1 --></div>
- <div id="mainContent">
- <h3> New Product</h3>
- <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>
- <form action="new_produk.php" method="post" name="newproduct" enctype="multipart/form-data">
- <table width="100%" border="0" id="table1">
- <tr>
- <th colspan="2" id="title">Add New Product</th>
- </tr>
- <tr>
- <td id="judul">Code Product</td>
- <td>:
- <input type="text" name="code" maxlength="10" size="85" /></td>
- </tr>
- <tr>
- <td width="140" id="judul">Product name</td>
- <td colspan="2">:
- <input type="text" name="name_product" maxlength="100" size="85" /></td>
- </tr>
- <tr>
- <td id="judul">Description</td>
- <td>:</td></tr>
- <tr>
- <td colspan="2"><textarea name="description" cols="85" rows="5"></textarea></td>
- </tr>
- <tr>
- <td id="judul">Category</td>
- <td>:
- <select name="category">
- <?php
- include"koneksi.php";
- $oke=mysql_query("select * from category order by name_category asc");
- while($data=mysql_fetch_array($oke)){
- echo"<option value='$data[name_category]'>-- $data[name_category] --";
- }
- ?>
- </option></select>
- </td>
- </tr>
- <tr>
- <td id="judul">Price</td>
- <td>:
- <input type="text" name="price" maxlength="10" size="25" /></td>
- </tr>
- <tr>
- <td id="judul">Stock</td>
- <td>
- <label>
- :
- <input type="radio" name="stock" value="ada" id="stock_0" />
- Ada</label>
-
- <label>
- <input type="radio" name="stock" value="kosong" id="stock_1" />
- Kosong</label>
- </td>
- </tr>
- <tr>
- <td id="judul">Status</td>
- <td>
- <label>
- :
- <input type="radio" name="status" value="public" id="status_0" />
- Public</label>
-
- <label>
- <input type="radio" name="status" value="draft" id="status_1" />
- Draft</label>
- </td>
- </tr>
- <tr>
- <td id="judul">Picture</td>
- <td>:
- <input name="picture" type="file" size="25"/></td>
- </tr>
- <tr>
- <td colspan="2"><br /><center>
- <input type="submit" name="simpan" value="Simpan" />
- <input type="reset" name="reset" value="Reset" />
- </center></td>
- </tr>
- </table>
- </form>
- </div>
- <br class="clearfloat" />
- <div id="footer">
- <center><p>© Powered 2013 All right reserved</p></center>
- <!-- end #footer --></div>
- <!-- end #container --></div>
- </body>
- </html>
- <?php
- if (isset($_POST['simpan']) !="")
- {
- //menyimpan gambar keserver//
- if ((($_FILES["picture"]["type"]=="image/gif") || ($_FILES["picture"]["type"]=="image/jpeg") || ($_FILES["picture"]["type"]=="image/pjpeg")) && ($_FILES["picture"]["size"]<2000))
- {
- if ($_FILES["picture"]["error"] > 0)
- {
- echo "Return Code:".$_FILES["picture"]["error"]."<br />";
- }
- else
- {
- echo "Upload:".$_FILES["picture"]["name"]."<br />";
- echo "Type: ".$_FILES["picture"]["type"]."<br />";
- echo "Size: ".($_FILES["picture"]["size"] / 1024)." Kb<br />";
- echo "Temp file: ".$_FILES["picture"]["tmp_name"]."<br />";
- if (file_exists("upload/" . $_FILES["picture"]["name"]))
- {
- echo $_FILES["picture"]["name"]."already exists. ";
- }
- else
- {
- move_uploaded_file($_FILES["picture"]["tmp_name"],"upload/" . $_FILES["picture"]["name"]);echo "Stored in: " . "upload/" . $_FILES["picture"]["name"];
- $file_name =$_FILES['picture']['name'];
- }
- }
- }
- else
- {
- echo "Invalid file";
- }
- //simpan kedatabases//
- include "db.php";
- $code=$_POST['code'];
- $name=$_POST['name_product'];
- $description=$_POST['description'];
- $category=$_POST['category'];
- $price=$_POST['price'];
- $status=$_POST['status'];
- $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());
- if ($data){
- echo "<script> alert ('Data Telah Tersimpan'); </script>" ;
- }
- else {
- echo "Anda gagal update";
- }
- }
- ?>
- <?php } ?>
Advertisement
Add Comment
Please, Sign In to add comment