|
Server IP : 2a02:4780:11:1596:0:cbc:26e7:10 / Your IP : 216.73.217.7 Web Server : LiteSpeed System : Linux in-mum-web1496.main-hosting.eu 5.14.0-611.38.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Mar 10 17:21:28 EDT 2026 x86_64 User : u213657319 ( 213657319) PHP Version : 8.3.30 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : OFF | Python : OFF Directory (0755) : /home/u213657319/domains/mutiyanglobal.com/public_html/admin/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<?php
session_start();
include 'check.php';
if(empty($_SESSION['emailId'])){
header("Location: index.php");
}
include '../connection.php';
include 'constant_file.php';
include 'includes/common_function.php';
$pid = $_GET['ct_id'];
$select = "SELECT * FROM products WHERE id = " . $pid . " AND status= '1'";
$res = mysqli_query($con,$select);
$fetch = mysqli_fetch_object($res);
//echo print_r($fetch); die();
//echo '<pre/>';print_r($details); die();
$display_message = '';
if (isset($_POST['update'])) {
//$p_type = $_POST['p_type'];
$lastId = '';
$ct_id = $_POST['ct_id'];
$c_id = $_POST['c_id'];
$p_name = $_POST['p_name'];
$p_stock = $_POST['p_stock'];
$p_price = $_POST['p_price'];
$p_description = $_POST['p_description'];
$cid = $_POST['c_id'];
$user_id = $_SESSION['uid'];
//echo "<pre />";print_r($_FILES['product_image']['name']);die();
$target_dir = ADMIN_PRODUCT_UPLOAD_PATH;
$imagename = $_FILES['product_image']['name'][0];
$target_file = $target_dir . $imagename;
$movefile = move_uploaded_file($_FILES['product_image']['tmp_name'][0], $target_file);
if (isset($movefile)) {
if ($pid != '') {
if($imagename !=''){
$query = "UPDATE products SET name = '".$p_name."', category = '".$ct_id."', sub_category = '".$c_id."', stock = '".$p_stock."', price = '".$p_price."', description = '".$p_description."', product_image = '".$imagename."' WHERE id = $pid";
}else{
$query = "UPDATE products SET name = '".$p_name."', category = '".$ct_id."', sub_category = '".$c_id."', stock = '".$p_stock."', price = '".$p_price."', description = '".$p_description."' WHERE id = $pid";
}
$result = mysqli_query($con,$query);
if (isset($_FILES['product_image']['name'])) {
if($imagename !=''){
$mg_query1 = "DELETE FROM product_image WHERE p_id=".$pid;
mysqli_query($con,$mg_query1);
$display_message = 'Product Updated';
$i = 0;
//print_r($_FILES['product_image']['name']);die();
foreach ($_FILES['product_image']['name'] as $imaglist) {
$img_name = $_FILES['product_image']['name'][$i];
$img_temp = $_FILES['product_image']['tmp_name'][$i];
$target_file2 = $target_dir . $img_name;
$addImage = move_uploaded_file($img_temp, $target_file2);
//print_r($addImage);
$mg_query = "INSERT INTO product_image(p_id, img_name) VALUES ('" . $pid . "', '" . $img_name . "')";
mysqli_query($con,$mg_query);
//die();
$i++;
}
}
}
header("Refresh:0");
}
}
}
?>
<html>
<head>
<?php
include 'includes/assets.php';
?>
<style>
.cke_notifications_area{
display: none;
}
</style>
</head>
<body class="skin-blue">
<div class="wrapper">
<?php
include 'includes/header.php';
?>
<!-- Left side column. contains the logo and sidebar -->
<?php
include 'includes/aside.php';
?>
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header" style="margin-left: 7%">
<h1><b>Update Product</b></h1>
<a href="view_product.php"> <button type="button" class="btn btn-primary" style="margin-left:38%">View Product</button></a>
</section>
<?php
echo $display_message;
?>
<!-- Main content -->
<section class="content" style="margin-left: 7%">
<div class="row">
<!-- left column -->
<div class="col-md-6">
<!-- general form elements -->
<div class="box box-primary">
<div class="box-header">
</div>
<form role="form" method="post" action="" enctype="multipart/form-data">
<input type="hidden" id = 'pid' name="pid" value="<?php echo $_GET['pid']; ?>">
<div class="box-body">
<div class="form-group">
<label for="exampleInputEmail1">Product Category</label>
<select class="form-control" id="producttype" placeholder="Product Type" name="ct_id">
<option>Select Your Product<small><b>*</b></small></option>
<?php
$query = mysqli_query($con,'SELECT * FROM category_type WHERE status = 1');
while($row = mysqli_fetch_array($query)){ ?>
<option value="<?php echo $row['id']; ?>" <?php if($row['id'] == $fetch->category){ echo "selected"; } ?>> <?php echo $row['category_type'] ?></option>
<?php }
?>
</select>
</div>
<?php if($fetch->sub_category != '0'){ ?>
<div class="form-group">
<label for="exampleInputEmail1">Sub Category</label>
<select class="form-control" id="producttype" placeholder="Product Type" name="c_id">
<option>Select Your Product<small><b>*</b></small></option>
<?php
$query = mysqli_query($con,'SELECT * FROM product_category WHERE ct_id ='.$fetch->category.' and status = 1');
while($row = mysqli_fetch_array($query)){ ?>
<option value="<?php echo $row['id']; ?>" <?php if($row['id'] == $fetch->sub_category){ echo "selected"; } ?>> <?php echo $row['c_name'] ?></option>
<?php }
?>
</select>
</div>
<?php } ?>
<div class="form-group">
<label for="exampleInputPassword1">Product Name</label>
<input type="text" name="p_name" value="<?php echo $fetch->name; ?>" class="form-control" id="exampleInputPassword1" placeholder="Product Name">
</div>
<div class="form-group">
<label for="exampleInputPassword1">Product Stock</label>
<input type="text" name="p_stock" value="<?php echo $fetch->stock; ?>" class="form-control" placeholder="Product Quantity">
</div>
<div class="form-group">
<label for="exampleInputPassword1">Product Price</label>
<input type="text" name="p_price" value="<?php echo $fetch->price; ?>" class="form-control" placeholder="Product Price">
</div>
<div class="form-group">
<label for="exampleInputPassword1">Product Description</label>
<textarea name="p_description" id="editor1" class="form-control" placeholder="Product Description"><?php echo $fetch->description; ?></textarea>
</div>
<div class="form-group" id="image-list">
<label for="exampleInputFile">Product Image</label>
<span class="add-multiple-image"><input type="button" value="Add Image"></span>
<input type="file" accept="image/*" name="product_image[]" id="exampleInputFile">
</div>
</div>
<!-- /.box-body -->
<div>
<?php
$imagelist = getImage($pid,$details='details');
foreach ($imagelist as $key => $value) {
?>
<img src=" product_image/<?php echo $value['img_name']; ?>" width="80px" height="50px">
<?php } ?>
</div>
<div class="box-footer">
<button type="submit" name="update" class="btn btn-primary">Update Product</button>
</div>
</form>
</div>
<!-- /.box -->
</div>
<!--/.col (left) -->
</div>
<!-- /.row -->
</section>
<!-- /.content -->
</div>
<!-- /.content-wrapper -->
<?php
include 'includes/footer.php';
?>
</div>
<!-- ./wrapper -->
<!-- jQuery 2.1.3 -->
<script src="plugins/jQuery/jQuery-2.1.3.min.js"></script>
<!-- Bootstrap 3.3.2 JS -->
<script src="bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<!-- FastClick -->
<script src='plugins/fastclick/fastclick.min.js'></script>
<!-- AdminLTE App -->
<script src="dist/js/app.min.js" type="text/javascript"></script>
<!-- AdminLTE for demo purposes -->
<script src="dist/js/demo.js" type="text/javascript"></script>
<script src="https://cdn.ckeditor.com/4.22.1/standard/ckeditor.js"></script>
<script>
CKEDITOR.replace('editor1');
</script>
</body>
</html>
<script type="text/javascript">
var html_image = '<input type="file" accept="image/*" name="product_image[]" id="exampleInputFile">';
$(document).ready(function() {
$('.add-multiple-image').click(function() {
$('#image-list').append(html_image);
});
$('#productfor').change(function() {
var ct_id = $(this).val();
var p_id = $('#pid').val();
window.location = "update_product.php?pid=" + p_id + "&ct_id=" + ct_id;
});
$('#size_type').change(function() {
console.log('run size');
var size_type = $(this).val();
var p_id = $('#pid').val();
var c_id = $('#producttype').val();
var ct_id = $('#productfor').val();
window.location = "update_product.php?pid=" + p_id + "&ct_id=" + ct_id + "&c_id=" + c_id + "&s_id=" + size_type;
});
});
</script>