Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- 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"]["type"]=="image/png")) && ($_FILES["picture"]["size"]<20000))
- {
- 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";
- $id=$_SESSION['id'];
- $code=$_POST['code'];
- $name_product=$_POST['name_product'];
- $description=$_POST['description'];
- $category=$_POST['category'];
- $price=$_POST['price'];
- $status=$_POST['status'];
- $stock=$_POST['stock'];
- if(isset($file_name)!=""){
- $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());
- }
- else{
- $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());
- }
- if ($data){
- echo "<script> alert ('Data Telah Tersimpan'); </script>" ;
- include "index.php";
- }
- else {
- echo "Anda gagal update";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment