drzeo

edit1

Apr 30th, 2015
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.22 KB | None | 0 0
  1. <?php
  2. session_start();
  3. if(isset($_POST['simpan'])!="")
  4. {
  5. //menyimpan gambar keserver//
  6. if ((($_FILES["picture"]["type"]=="image/gif") || ($_FILES["picture"]["type"]=="image/jpeg") || ($_FILES["picture"]["type"]=="image/pjpeg") || ($_FILES["picture"]["type"]=="image/png")) && ($_FILES["picture"]["size"]<20000))
  7. {
  8.    if ($_FILES["picture"]["error"] > 0)  
  9.    {
  10.      echo "Return Code:".$_FILES["picture"]["error"]."<br />";
  11.    }  
  12.    else
  13.    {
  14.      echo "Upload:".$_FILES["picture"]["name"]."<br />";
  15.      echo "Type: ".$_FILES["picture"]["type"]."<br />";
  16.      echo "Size: ".($_FILES["picture"]["size"] / 1024)." Kb<br />";
  17.      echo "Temp file: ".$_FILES["picture"]["tmp_name"]."<br />";
  18.      
  19.      if (file_exists("upload/" . $_FILES["picture"]["name"]))
  20.      {
  21.        echo $_FILES["picture"]["name"]."already exists. ";
  22.      }
  23.      else
  24.      {
  25.        move_uploaded_file($_FILES["picture"]["tmp_name"],"upload/" . $_FILES["picture"]["name"]);echo "Stored in: " . "upload/" . $_FILES["picture"]["name"];
  26.        $file_name =$_FILES['picture']['name'];
  27.      }
  28.    }
  29. }
  30. else
  31. {
  32. echo "Invalid file";
  33. }
  34. //simpan kedatabases//
  35. include "db.php";
  36. $id=$_SESSION['id'];
  37. $code=$_POST['code'];
  38. $name_product=$_POST['name_product'];
  39. $description=$_POST['description'];
  40. $category=$_POST['category'];
  41. $price=$_POST['price'];
  42. $status=$_POST['status'];
  43. $stock=$_POST['stock'];
  44. if(isset($file_name)!=""){
  45. $data=mysql_query ("UPDATE product SET code_product='$code', name_product='$name_product', category_product='$category', description_product='$description', price_product='$price', status_product='$status', stock_product='$stock',      picture_product='$file_name', author_product='$_SESSION[username]' where id_product='$id' ") or die (mysql_error());
  46. }
  47. else{
  48. $data=mysql_query ("UPDATE product SET code_product='$code', name_product='$name_product', category_product='$category', description_product='$description', price_product='$price', status_product='$status', stock_product='$stock', author_product='$_SESSION[username]' where id_product='$id' ") or die (mysql_error());
  49. }
  50. if ($data){
  51.     echo "<script> alert ('Data Telah Tersimpan'); </script>" ;
  52.     include "index.php";
  53.     }
  54. else {
  55.     echo "Anda gagal update";  
  56. }
  57. }
  58. ?>
Advertisement
Add Comment
Please, Sign In to add comment