[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: edit_product.php
<?php include('header.php'); ?> <style> .col-md-6,.col-md-4,.col-md-3,.col-md-2,.col-md-5{ display:inline-block !important; } </style> <div class="main-panel"> <div class="content"> <div class="container-fluid"> <div class="row"> <div class="col-md-12"> <div class="card"> <div class="card-header"> <div class="card-title">Edit Product</div> </div> <?php $sr='product'; $stmt =$show->readwithdata($sr,'id',$_REQUEST['id']); $num = $stmt->rowCount(); if($num>0){ $count=1; while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){ $ptitle=$row['title']; $description=$row['description']; $product_id=$row['product_id']; $size=explode(',',$row['size']); ?> <form method="post" id="exampleValidation" data-toggle="validator" enctype="multipart/form-data" > <div class="card-body"> <div class="form-group"> <div class="col-md-2"> <label>Product Category</label> <select name="category" class="form-control" required> <option value="">Category</option> <?php $table1='category'; $stmt1=$show->readAll($table1); $num1=$stmt1->rowCount(); if($num1>0){ while($row1=$stmt1->fetch(PDO::FETCH_ASSOC)){ echo "<option value='".$row1['category']."'";if($row['category']==$row1['category']) echo "selected"; echo ">".$row1['category']."</option>"; } } ?> </select> </div> <div class="col-md-3"> <label>Product Sub Category</label> <select name="sub_category" class="form-control" required> <option value="">Sub Category</option> <?php $stmt11=$show->readAll('sub_category'); $num=$stmt11->rowCount(); while($row11=$stmt11->fetch(PDO::FETCH_ASSOC)){ echo "<option value='".$row11['sub_category']."'";if($row11['sub_category']==$row['sub_category']) echo "selected"; echo ">".$row11['sub_category']."</option>"; } ?> </select> </div> <div class="col-md-3"> <label>Product Type</label> <select name="type" class="form-control"> <option value="">Type</option> <?php $stmt=$show->readAll('type'); $num=$stmt->rowCount(); if($num>0){ while($row1=$stmt->fetch(PDO::FETCH_ASSOC)){ echo "<option value='".$row1['type']."'";if($row['type']==$row1['type']) echo "selected"; echo ">".$row1['type']."</option>"; } } ?> </select> </div> <div class="col-md-3"> <label>Gender</label> <?php $interests = array('Male','Female','Unisex'); ?> <select name="gender" class="form-control" id="gender<?=$count;?>"> <?php foreach( $interests as $interest ): ?> <option value="<?php echo $interest ?>"<?php if( $interest==$row['gender']): ?> selected="selected"<?php endif; ?>><?php echo $interest ?></option> <?php endforeach; ?> </select> </div> </div> <div class="form-group"> <div class="col-md-2"> <label>Color</label> <select name="color" class="form-control" id="scate"> <option value="">Color</option> <?php $stmt12=$show->readAll('color'); $num=$stmt->rowCount(); if($num>0){ while($row12=$stmt12->fetch(PDO::FETCH_ASSOC)){ echo "<option value='".$row12['color']."'";if($row['color']==$row12['color']) echo "selected"; echo ">".$row12['color']."</option>"; } } ?> </select> </div> <div class="col-md-2"> <label>Fabric</label> <select name="fabric" class="form-control" id="scate"> <option value="">Fabric</option> <?php $stmt13=$show->readAll('fabric'); $num=$stmt->rowCount(); if($num>0){ while($row13=$stmt13->fetch(PDO::FETCH_ASSOC)){ echo "<option value='".$row13['fabric']."'";if($row['fabric']==$row13['fabric']) echo "selected"; echo ">".$row13['fabric']."</option>"; } } ?> </select> </div> <div class="col-md-2"> <label>Size</label> <?php $interests = array('XS','S','M','L','XL','XXL','XXXL','Free'); ?> <?php foreach ($interests as $val): ?> <input type="checkbox" name="size[]" value="<?=$val?>" <?=in_array($val, $size) ? "checked" : "" ?> > <?= strtoupper($val) ?> <?php endforeach; ?> </div> <div class="col-md-5"> <label>Title <span class="required-label">*</span></label> <input type="text" class="form-control" id="name" name="title" value="<?=$ptitle?>" placeholder="Enter Name" > </div> </div> <div class="form-group form-show-validation row"> <label>Description <span class="required-label"></span></label> <div class="col-lg-12 col-md-9 col-sm-8"> <textarea class="form-control" name="description"><?=$description?></textarea> </div> </div> <div class="form-group"> <div class="col-md-4"> <label>Product Price</label> <input type="text" class="form-control" value="<?=$row['price']?>"name="price" placeholder="Product Price"> </div> <div class="col-md-4"> <label>Product Discounted Price</label> <input type="text" class="form-control" value="<?=$row['discounted_price']?>" name="discounted_price" placeholder="Product Discounted Price"> </div> </div> <div class="form-group form-show-validation row"> <label for="email" class="col-lg-1 col-md-3 col-sm-4 mt-sm-2 text-right">Images<span class="required-label">*</span></label> <?php $c=1; $sq=$show->readwithdata('product_img','product_id',$product_id); while ($row1 = $sq->fetch(PDO::FETCH_ASSOC)){ $img=$row1['img']; ?> <div class="col-lg-2 col-md-9 col-sm-8"> <img src="<?=$pic_img?>/<?=$row1['img']?>" alt="" width="100px"/> <input type="file" name="uploadImg[]"> </div> <?php ++$c;} ?> </div> </div> <div class="seperator-solid"></div> <div class="card-action"> <div class="row"> <div class="col-md-12"> <input class="btn btn-success" type="submit" name="sub" value="Update"> <button class="btn btn-danger">Cancel</button> </div> </div> </div> </form> <?php } } ?> </div> </div> <?php if(isset($_POST['sub'])){ $s1="delete from product_size where product_id='".$product_id."'"; $s12=$con->prepare($s1); $s12->execute(); $price=$_POST['price']; $price1=$_POST['discounted_price']; $dis=$price-$price1; $total_dis=$dis/$price; $dis_per=$total_dis*100; $discount=round($dis_per); $size=array(); if(isset($_POST['size'])){ foreach($_POST['size'] as $key=>$val){ $size[]=$_POST['size'][$key]; // echo $_POST['size'][$key]; $size1 .=$size.":"; $data = array( 'product_id' => $product_id, 'size' =>$val, ); print_r($data); $show->insert('product_size',$data); } } $total_size=implode(",",$size); $allowed = ["title","category","description","type","gender","color","sub_category","size","fabric"]; $params = []; $setStr = ""; foreach ($allowed as $key) { if (isset($_POST[$key]) && $key != "uid") { $setStr .= "`$key` = :$key,"; $params[$key] = htmlspecialchars($_POST[$key]); } } if(isset($_FILES['uploadImg'])){ foreach($_FILES['uploadImg']['tmp_name'] as $key=>$value){ $img1=$show->imageEdit($_FILES['uploadImg']['name'][$key]); $data1 = array( 'product_id' => $product_id, 'img' => $img1, ); if(move_uploaded_file($_FILES['uploadImg']['tmp_name'][$key],"../product_img/".$img1)){ if($show->insert('product_img',$data1)){ } } } } $setStr .="`price`=:price,`discounted_price`=:discounted_price,`discount`=:discount,`size`=:size,"; $setStr = rtrim($setStr, ","); $params['product_id'] =$product_id; $params['price'] =$price; $params['discounted_price'] =$price1; $params['discount'] =$discount; $params['size'] =$total_size; $show->table ='product'; $show->cols =$setStr; $show->id_name ='product_id'; $show->params =$params; //print_r($params); if($show->update_all()){ echo '<script> setTimeout(function() { swal({ title: "Thank You ", text: "for Updating!", type: "success" }, function() { window.location = "'.$_SERVER['REQUEST_URI'].'"; }); }, 1000); </script>'; } else{ echo "ss"; } }?> </div></div> </div> </div> <!--footer--> <?php include('footer.php'); ?>
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server05.hostinghome.co.in
Server IP: 192.168.74.40
PHP Version: 7.4.33
Server Software: Apache
System: Linux server05.hostinghome.co.in 3.10.0-962.3.2.lve1.5.81.el7.x86_64 #1 SMP Wed May 31 10:36:47 UTC 2023 x86_64
HDD Total: 1.95 TB
HDD Free: 692.03 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Disabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: itsweb
User ID (UID): 1619
Group ID (GID): 1621
Script Owner UID: 1619
Current Dir Owner: 1619