MMCT TEAM
Server IP : 2a02:4780:11:1596:0:cbc:26e7:10  /  Your IP : 216.73.216.78
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/neoriseventures.in/public_html/admin/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/u213657319/domains/neoriseventures.in/public_html/admin/edit_product.php
<?php

if(!isset($_SESSION['admin_email'])){

echo "<script>window.open('login.php','_self')</script>";

}

else {

?>

<?php

if(isset($_GET['edit_product'])){

$edit_id =mysqli_real_escape_string($con,$_GET['edit_product']);

$get_p = "select * from products where product_id='$edit_id'";

$run_edit = mysqli_query($con,$get_p);

$row_edit = mysqli_fetch_array($run_edit);

$p_id = $row_edit['product_id'];

$p_title = $row_edit['product_title'];

$p_cat = $row_edit['p_cat_id'];

$cat = $row_edit['cat_id'];

$p_image1 = $row_edit['product_img1'];

$p_image2 = $row_edit['product_img2'];

$p_image3 = $row_edit['product_img3'];
//$amount = $row_edit['amount'];
//$gst = $row_edit['gst'];

//$p_price = $row_edit['product_price'];

$p_desc = $row_edit['product_desc'];

$p_keywords = $row_edit['product_keyword'];

}

$get_p_cat = "select * from product_category where p_cat_id='$p_cat'";

$run_p_cat = mysqli_query($con,$get_p_cat);

$row_p_cat = mysqli_fetch_array($run_p_cat);

$p_cat_title = $row_p_cat['p_cat_title'];

$get_cat = "select * from categories where cat_id='$cat'";

$run_cat = mysqli_query($con,$get_cat);

$row_cat = mysqli_fetch_array($run_cat);

$cat_title = $row_cat['cat_title'];

?>


<!DOCTYPE html>

<html>

<head>

<title> Edit Products </title>



</head>

<body>

<div class="row"><!-- row Starts -->

<div class="col-lg-12"><!-- col-lg-12 Starts -->

<ol class="breadcrumb"><!-- breadcrumb Starts -->

<li class="active">

<i class="fa fa-dashboard"> </i> Dashboard / Edit Products

</li>

</ol><!-- breadcrumb Ends -->

</div><!-- col-lg-12 Ends -->

</div><!-- row Ends -->


<div class="row"><!-- 2 row Starts --> 

<div class="col-lg-12"><!-- col-lg-12 Starts -->

<div class="panel panel-default"><!-- panel panel-default Starts -->

<div class="panel-heading"><!-- panel-heading Starts -->

<h3 class="panel-title">

<i class="fa fa-money fa-fw"></i> Edit Products

</h3>

</div><!-- panel-heading Ends -->

<div class="panel-body"><!-- panel-body Starts -->

<form class="form-horizontal" method="post" enctype="multipart/form-data"><!-- form-horizontal Starts -->

<div class="form-group" ><!-- form-group Starts -->

<label class="col-md-3 control-label" > Product Title </label>

<div class="col-md-6" >

<input type="text" name="product_title" class="form-control" required value="<?php echo $p_title; ?>">

</div>

</div><!-- form-group Ends -->

<div class="form-group" ><!-- form-group Starts -->

<label class="col-md-3 control-label" > Product Category </label>

<div class="col-md-6" >

<select name="product_cat" class="form-control" >

<option value="<?php echo $p_cat; ?>" > <?php echo $p_cat_title; ?> </option>


<?php

$get_p_cats = "select * from product_category";

$run_p_cats = mysqli_query($con,$get_p_cats);

while ($row_p_cats=mysqli_fetch_array($run_p_cats)) {

$p_cat_id = $row_p_cats['p_cat_id'];

$p_cat_title = $row_p_cats['p_cat_title'];

echo "<option value='$p_cat_id' >$p_cat_title</option>";

}


?>


</select>

</div>

</div><!-- form-group Ends -->

<!--
<div class="form-group" >

<label class="col-md-3 control-label" > Category </label>

<div class="col-md-6" >


<select name="cat" class="form-control" >

<option value="<?php echo $cat; ?>" > <?php echo $cat_title; ?> </option>

<?php

$get_cat = "select * from categories ";

$run_cat = mysqli_query($con,$get_cat);

while ($row_cat=mysqli_fetch_array($run_cat)) {

$cat_id = $row_cat['cat_id'];

$cat_title = $row_cat['cat_title'];

echo "<option value='$cat_id'>$cat_title</option>";

}

?>


</select>

</div>

</div> form-group Ends -->

<div class="form-group" ><!-- form-group Starts -->

<label class="col-md-3 control-label" > Product Image 1 </label>

<div class="col-md-6" >

<input type="file" name="product_img1" class="form-control"  >
<br><img src="product_images/<?php echo $p_image1; ?>" width="70" height="70" >

</div>

</div><!-- form-group Ends -->

<div class="form-group" ><!-- form-group Starts -->

<label class="col-md-3 control-label" > Product Image 2 </label>

<div class="col-md-6" >

<input type="file" name="product_img2" class="form-control"  >
<br><img src="product_images/<?php echo $p_image2; ?>" width="70" height="70" >

</div>

</div><!-- form-group Ends -->

<div class="form-group" ><!-- form-group Starts -->

<label class="col-md-3 control-label" > Product Image 3 </label>

<div class="col-md-6" >

<input type="file" name="product_img3" class="form-control"  >
<br><img src="product_images/<?php echo $p_image3; ?>" width="70" height="70" >

</div>

</div><!-- form-group Ends -->

<!---<div class="form-group" >

<label class="col-md-3 control-label" > Product Price </label>

<div class="col-md-6" >

<input type="text" name="amount" class="form-control" id="price" required value="<?php echo $amount; ?>" >

</div>

</div>

<div class="form-group" >

<label class="col-md-3 control-label" > Total GST % </label>

<div class="col-md-6" >

<input type="text" name="gst" class="form-control" id="gst" required value="<?php echo $gst; ?>" >

</div>

</div>

<div class="form-group" >

<label class="col-md-3 control-label" > Total Amount </label>

<div class="col-md-6" >

<input type="text" name="product_price" class="form-control" id="total"  value="<?php echo $p_price; ?>" >

</div>

</div>-------><!-- form-group Ends -->

<div class="form-group" ><!-- form-group Starts -->

<label class="col-md-3 control-label" > Product Keywords </label>

<div class="col-md-6" >

<input type="text" name="product_keyword" class="form-control" required value="<?php echo $p_keywords; ?>" >

</div>

</div><!-- form-group Ends -->

<div class="form-group" ><!-- form-group Starts -->

<label class="col-md-3 control-label" > Product Description </label>

<div class="col-md-6" >

<textarea name="product_desc" class="form-control" rows="6" cols="19" >
<?php echo $p_desc; ?>
</textarea>

</div>

</div><!-- form-group Ends -->

<div class="form-group" ><!-- form-group Starts -->

<label class="col-md-3 control-label" ></label>

<div class="col-md-6" >

<input type="submit" name="update" value="Update Product" class="btn btn-primary form-control" >

</div>

</div><!-- form-group Ends -->

</form><!-- form-horizontal Ends -->

</div><!-- panel-body Ends -->

</div><!-- panel panel-default Ends -->

</div><!-- col-lg-12 Ends -->

</div><!-- 2 row Ends --> 




<script>
$(document).ready(function() {
  $('#gst').keyup(function(ev) {
    cal();
  });
  $('#price').keyup(function(ev) {
    cal();
  });
  $('#qty').keyup(function(ev) {
    cal();
  });
  function cal()
  {
    var gst = 0;
    var price = 0;
    var qty = 0;
    var amount = 0;    
    var total = 0;
    price = $('#price').val();
    if(price ) 
    {
      price = $("#price").val();
      if(price > 0)
      {
        amount = parseFloat(price)
        gst = $("#gst").val();
        if(gst > 0)
        {
          gst =  parseFloat(amount) * parseFloat(gst) / 100;
          total = parseFloat(amount) - parseFloat(gst);
          $('#total').val(total);          
          $('#total_gst').val(gst);
        }
        else
        {
          total = parseFloat(amount);
          $('#total').val(total);
          $('#total_gst').val(gst);
        }
      }
    }
    
  }
});
</script>


</body>

</html>

<?php

if(isset($_POST['update'])){

$product_title        = mysqli_real_escape_string($con,$_POST['product_title']);
$product_cat          = mysqli_real_escape_string($con,$_POST['product_cat']);
$cat                  = mysqli_real_escape_string($con,$_POST['cat']);
$product_price        = mysqli_real_escape_string($con,$_POST['product_price']);
$product_desc         = mysqli_real_escape_string($con,$_POST['product_desc']);
$product_keyword      = mysqli_real_escape_string($con,$_POST['product_keyword']);
$amount               = mysqli_real_escape_string($con,$_POST['amount']);
$gst                  = mysqli_real_escape_string($con,$_POST['gst']);



$update_product = "update products set p_cat_id='$product_cat',cat_id='$cat',date=NOW(),product_title='$product_title',";







	if($_FILES['product_img1']['size'] != 0){
  $img1     = $_FILES['product_img1']['name'];
    $img1     = preg_replace("/\s+/","_",$img1);
    $img_ext1 = pathinfo($img1, PATHINFO_EXTENSION);
    $img1     = pathinfo($img1, PATHINFO_FILENAME);
    $product_img1    = $img1."_".date("mjyhis").".".$img_ext1;
    $imgtmp1    = $_FILES['product_img1']['tmp_name'];
  move_uploaded_file($imgtmp1, "product_images/$product_img1");
  $update_product .= " `product_img1`='$product_img1' , ";
}
elseif($_FILES['product_img1']['size'] = 0){
  $img1     = $_FILES['product_img1']['name'];
    $img1     = preg_replace("/\s+/","_",$img1);
    $img_ext1 = pathinfo($img1, PATHINFO_EXTENSION);
    $img1     = pathinfo($img1, PATHINFO_FILENAME);
    $product_img1    = $img1."_".date("mjyhis").".".$img_ext1;
    $imgtmp1    = $_FILES['product_img1']['tmp_name'];
  move_uploaded_file($imgtmp1, "product_images/$product_img1");
  $update_product .= " `product_img1`='$product_img1' , ";
}


	if($_FILES['product_img2']['size'] != 0){
   $img2     = $_FILES['product_img2']['name'];
    $img2     = preg_replace("/\s+/","_",$img2);
    $img_ext2 = pathinfo($img2, PATHINFO_EXTENSION);
    $img2     = pathinfo($img2, PATHINFO_FILENAME);
    $product_img2    = $img2."_".date("mjyhis").".".$img_ext2;
    $imgtmp2    = $_FILES['product_img2']['tmp_name'];
  move_uploaded_file($imgtmp2, "product_images/$product_img2");
  $update_product .= " `product_img2`='$product_img2' , ";
}
elseif($_FILES['product_img2']['size'] = 0){
   $img2     = $_FILES['product_img2']['name'];
    $img2     = preg_replace("/\s+/","_",$img2);
    $img_ext2 = pathinfo($img2, PATHINFO_EXTENSION);
    $img2     = pathinfo($img2, PATHINFO_FILENAME);
    $product_img2    = $img2."_".date("mjyhis").".".$img_ext2;
    $imgtmp2    = $_FILES['product_img2']['tmp_name'];
  move_uploaded_file($imgtmp2, "product_images/$product_img2");
  $update_product .= " `product_img2`='$product_img2' , ";
}




	if($_FILES['product_img3']['size'] != 0){
    $img3     = $_FILES['product_img3']['name'];
    $img3     = preg_replace("/\s+/","_",$img3);
    $img_ext3 = pathinfo($img3, PATHINFO_EXTENSION);
    $img3     = pathinfo($img3, PATHINFO_FILENAME);
    $product_img3    = $img3."_".date("mjyhis").".".$img_ext3;
    $imgtmp3    = $_FILES['product_img3']['tmp_name'];
  move_uploaded_file($imgtmp3, "product_images/$product_img3");
  $update_product .= " `product_img3`='$product_img3' , ";
}
elseif($_FILES['product_img3']['size'] = 0){
  $img3     = $_FILES['product_img3']['name'];
    $img3     = preg_replace("/\s+/","_",$img3);
    $img_ext3 = pathinfo($img3, PATHINFO_EXTENSION);
    $img3     = pathinfo($img3, PATHINFO_FILENAME);
    $product_img3    = $img3."_".date("mjyhis").".".$img_ext3;
    $imgtmp3    = $_FILES['product_img3']['tmp_name'];
  move_uploaded_file($imgtmp3, "product_images/$product_img3");
  $update_product .= " `product_img3`='$product_img3' , ";
}


$update_product .= "amount='$product_price',gst='$gst',product_price='$amount',product_desc='$product_desc',product_keyword='$product_keyword' where product_id='$p_id'";



$run_product = mysqli_query($con,$update_product);

if($run_product){

echo "<script> alert('Product has been updated successfully') </script>";

echo "<script>window.open('index.php?view_product','_self')</script>";

}

}

?>

<?php } ?>

MMCT - 2023