Uname : Linux V-ShopU01 4.18.0-348.20.1.el8_5.x86_64 #1 SMP Thu Mar 10 20:59:28 UTC 2022 x86_64
Server : Apache/2.4.37 (rocky) OpenSSL/1.1.1k
Whoami : apache
Safe Mode : OFF
DOCUMENT ROOT : /var/www/html/site_shopudietDisable Function :
Path : /var/www/html/site_shopudiet/admin/
Server IP : 65.20.74.164
Client IP : 3.16.68.49
Current File : /var/www/html/site_shopudiet/admin/product_update.php |
<?php
include 'dbconnect.php';
include 'lib/ImageResize.php';
use \Gumlet\ImageResize;
$home_id=$_GET['id'];
$cat =$_POST['category_name'];
$purchase_total =$_POST['purchase_total'];
$purchase_amount =$_POST['purchase_amount'];
$purchase_gst =$_POST['purchase_gst'];
$product_code=$_POST['product_code'];
$hashtag = implode(',',$_POST['hashtag']);
$delivery_time = $_POST['delivery_time'];
$super_category = $_POST['super_category'];
$sub_cat=implode(',', $_POST['subcategory']);
$st =$_POST['stock'];
if($st == '') { $stock = 20;} else { $stock = $st;}
$orgnon =$_POST['orgnon'];
$p_name=addslashes($_POST['product_name']);
$price=$_POST['price'];
$weight=$_POST['weight'];
if(isset($_POST['new_arrival'])) {
$new_arrival = $_POST['new_arrival'];
}
else { $new_arrival = 0; }
$desc=addslashes($_POST['description']);
$manuf_name=addslashes($_POST['manuf']);
$sql = mysqli_query($conn,"SELECT * FROM brand WHERE brand_name='$manuf_name'");
while($row1 = mysqli_fetch_array($sql)) {
$brand_id = $row1['id'];
}
$discount=$_POST['discount'];
$cgst = $_POST['cgst'];
$sgst = $_POST['sgst'];
$gst = $cgst+$sgst;
if($gst == '') { $gst = 5; }
if(empty($discount)){
$disc_rate=0;
}
else{
$disc_rate=$price-($price*($discount/100));
}
$squery = "select * from product WHERE id='$home_id'";
$result = mysqli_query($conn, $squery);
while( $row = mysqli_fetch_array($result))
{
$imag=$row['file1'];
if($_FILES["file1"]["name"] != NULL)
{
$uniquesavename=time().uniqid(rand());
$file_name1 = $uniquesavename;
$target_file = "img/".$uniquesavename;
move_uploaded_file($_FILES["file1"]["tmp_name"], $target_file);
} else $filename1=NULL;
if ($conn->connect_error)
{
die("connecion failed:" .$conn->connect_error);
}
$a = null;
if($file_name1==$a)
{
mysqli_query($conn," UPDATE product SET brand_id='$brand_id',category_name='$cat',product_name='$p_name',price='$price',file1='$imag',description='$desc',prdct_code='$product_code',manuf_name='$manuf_name',discount='$discount',mrp='$disc_rate',weight='$weight',sub_category='$sub_cat',org_status='$orgnon',stock='$stock',purchase_total='$purchase_total',purchase_amount='$purchase_amount',purchase_gst='$purchase_gst',super_category='$super_category',hashtag='$hashtag',delivery_time='$delivery_time',new_arrival='$new_arrival' WHERE id='$home_id'");
if(mysqli_affected_rows($conn) > 0)
{
header("Location: product_list.php");
} else
{
header("Location: product_list.php");
echo mysqli_error ($conn);
}
}
else
{
$re = mysqli_query($conn," UPDATE product SET brand_id='$brand_id',category_name='$cat',product_name='$p_name',price='$price',file1='$file_name1',description='$desc',prdct_code='$product_code',manuf_name='$manuf_name',discount='$discount',mrp='$disc_rate',weight='$weight',sub_category='$sub_cat',org_status='$orgnon',stock='$stock',purchase_total='$purchase_total',purchase_amount='$purchase_amount',purchase_gst='$purchase_gst',super_category='$super_category',hashtag='$hashtag',delivery_time='$delivery_time',new_arrival='$new_arrival' WHERE id='$home_id'");
if(mysqli_affected_rows($conn) > 0)
{
header("Location: product_list.php");
} else
{
header("Location: product_list.php");
echo mysqli_error ($conn);
}
}
$imag1=$row['file2'];
if($_FILES["file2"]["name"] != NULL)
{
$uniquesavename2=time().uniqid(rand());
$file_name2 = $uniquesavename2;
$target_file = "img/".$uniquesavename2;
move_uploaded_file($_FILES["file2"]["tmp_name"], $target_file);
} else $filename2=NULL;
if ($conn->connect_error)
{
die("connecion failed:" .$conn->connect_error);
}
$a= null;
if($file_name2==$a)
{
mysqli_query($conn," UPDATE product SET category_name='$cat',product_name='$p_name',price='$price',file2='$imag1',description='$desc',prdct_code='$product_code',manuf_name='$manuf_name',discount='$discount',mrp='$disc_rate',weight='$weight',cgst='$cgst',sgst='$sgst',gst='$gst',purchase_total='$purchase_total',purchase_amount='$purchase_amount',purchase_gst='$purchase_gst',super_category='$super_category',hashtag='$hashtag',delivery_time='$delivery_time',new_arrival='$new_arrival' WHERE id='$home_id' ");
if(mysqli_affected_rows($conn) > 0)
{
header("Location: product_list.php");
} else
{
header("Location: product_list.php");
echo mysqli_error ($conn);
}
}
else
{
mysqli_query($conn," UPDATE product SET category_name='$cat',product_name='$p_name',price='$price',file2='$file_name2',description='$desc',prdct_code='$product_code',manuf_name='$manuf_name',discount='$discount',mrp='$disc_rate',weight='$weight',cgst='$cgst',sgst='$sgst',gst='$gst',purchase_total='$purchase_total',purchase_amount='$purchase_amount',purchase_gst='$purchase_gst',super_category='$super_category',hashtag='$hashtag',delivery_time='$delivery_time',new_arrival='$new_arrival' WHERE id='$home_id' ");
if(mysqli_affected_rows($conn) > 0)
{
header("Location: product_list.php");
} else
{
header("Location: product_list.php");
echo mysqli_error ($conn);
}
}
$imag2=$row['file3'];
if($_FILES["file3"]["name"] != NULL)
{
$uniquesavename3=time().uniqid(rand());
$file_name3 = $uniquesavename3;
$target_file = "img/".$uniquesavename3;
move_uploaded_file($_FILES["file3"]["tmp_name"], $target_file);
} else $filename1=NULL;
if ($conn->connect_error)
{
die("connecion failed:" .$conn->connect_error);
}
$a= null;
if($file_name3==$a)
{
mysqli_query($conn," UPDATE product SET category_name='$cat',product_name='$p_name',price='$price',file3='$imag2',description='$desc',prdct_code='$product_code',manuf_name='$manuf_name',discount='$discount',mrp='$disc_rate',weight='$weight',cgst='$cgst',sgst='$sgst',gst='$gst',purchase_total='$purchase_total',purchase_amount='$purchase_amount',purchase_gst='$purchase_gst',super_category='$super_category',hashtag='$hashtag',delivery_time='$delivery_time',new_arrival='$new_arrival' WHERE id='$home_id' ");
if(mysqli_affected_rows($conn) > 0)
{
header("Location: product_list.php");
} else
{
header("Location: product_list.php");
echo mysqli_error ($conn);
}
}
else
{
mysqli_query($conn," UPDATE product SET category_name='$cat',product_name='$p_name',price='$price',file3='$file_name3',description='$desc',prdct_code='$product_code',manuf_name='$manuf_name',discount='$discount',mrp='$disc_rate',weight='$weight',purchase_total='$purchase_total',purchase_amount='$purchase_amount',purchase_gst='$purchase_gst',super_category='$super_category',hashtag='$hashtag',delivery_time='$delivery_time',new_arrival='$new_arrival' WHERE id='$home_id' ");
}
$images=array(
'img/'.$file_name1,
'img/'.$file_name2,
'img/'.$file_name3,
);
foreach ( $images as $key => $images) {
if($images!='img/'){
$image = new ImageResize($images);
$image->scale(50);
$image->save('mobile/'.$images);
}
header("Location: product_list.php");
/* if(mysqli_affected_rows($conn) > 0)
{
header("Location: product_list.php");
} else
{
header("Location: product_list.php");
echo mysqli_error ($conn);
}*/
}
}
?>