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 : 18.116.10.201
Current File : /var/www/html/site_shopudiet/admin/add_diet.php |
<?php
include 'dbconnect.php';
$category_name = $_POST['category_name'];
$product_name = $_POST['product_name'];
$description = $_POST['description'];
$items = implode(',', $_POST['items']);
// $count=count($items);
// $s_weight = implode(',', $s_weight);
$image_name = basename($_FILES["image"]["name"]);
$target_file = "./img/".basename($_FILES["image"]["name"]);
move_uploaded_file($_FILES["image"]["tmp_name"], $target_file);
mysqli_query($conn," INSERT INTO `diet_chart`(`category_name`, `product_name`, `description`, `items`,`image`) VALUES ('$category_name','$product_name','$description','$items','$image_name') ");
if(mysqli_affected_rows($conn) > 0){
$last_id = mysqli_insert_id($conn);
// echo $last_id;
$sam=explode(",",$items);
$count=count($sam);
for($i=0;$i<count($sam);$i++){
$item1= $sam[$i];
// echo $item1;
$sql1="select * from product where product_name='".$item1."'";
$result = mysqli_query($conn,$sql1);
$row = mysqli_fetch_array($result);
$s_weight[]= $row['weight'];
$s_prdctid[]= $row['id'];
$s_prdctprice[]= $row['price'];
}
// for($i=0;$i<count($s_weight);$i++){
// echo $s_weight[$i];
// }
$s_weight = implode(',', $s_weight);
$s_prdctid = implode(',', $s_prdctid);
$s_prdctprice = implode(',', $s_prdctprice);
// echo $s_weight;
mysqli_query($conn," UPDATE diet_chart SET s_weight = '".$s_weight."',prdct_id= '". $s_prdctid."',prdct_price= '". $s_prdctprice."',num = '".$count."' WHERE id =".$last_id."");
echo "<script> alert('Successfull'); window.location.href='diet_view.php'; </script>";
} else {
echo mysqli_error ($conn);
}
?>