D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
var
/
www
/
vhosts
/
sarainternational.ae
/
httpdocs
/
admin
/
Filename :
product_edit.php
back
Copy
<?php include('include/header.php'); $id=$_GET['eid']; $sql=mysqli_query($conn,"select * from products where id='$id'"); $fetch=mysqli_fetch_array($sql); if(isset($_POST['update'])) { $id = $_POST['id']; $category =$_POST['addcategory']; $sku = $_POST['sku']; $title =$_POST['title']; $desc =$_POST['desc']; $additional = $_POST['additional']; $date = date('Y/m/d'); $filename = $_FILES['image']['name']; $tmpname = $_FILES['image']['tmp_name']; $unique = uniqid()." ".$filename; $store = "images/subproduct/".$unique; move_uploaded_file($tmpname,$store); $meta_title = $_POST['metatitle']; $meta_desc = $_POST['metadesc']; $meta_key = $_POST['metakey']; $text = strtolower($title); $desc = $_POST['desc']; $replaceArray1 = array( // '"' => """, "'" => "'", ); $modifiedText1 = str_replace(array_keys($replaceArray1), array_values($replaceArray1), $desc); $additional = $_POST['additional']; $replaceArray2 = array( '"' => """, "'" => "'", ); $modifiedText2 = str_replace(array_keys($replaceArray2), array_values($replaceArray2), $additional); if ((!($_FILES['image']['name']))) { $updateData=mysqli_query($conn,"update products set id='$id',category='$category',sku='$sku',title='$text',description='$modifiedText1',additional_info='$modifiedText2',createDate= '$date',meta_title='$meta_title',meta_description='$meta_desc',meta_keywords='$meta_key' where id='$id'"); } else { $updateData=mysqli_query($conn,"update products set id='$id',category='$category',sku='$sku',title='$text',description='$modifiedText1',additional_info='$modifiedText2',image='$store',createDate= '$date',meta_title='$meta_title',meta_description='$meta_desc',meta_keywords='$meta_key' where id='$id'"); } if($updateData) { echo "<script>alert('Data Updated');window.location.href='products.php';</script>"; } else { echo mysqli_error($conn); } } ?> <!-- Content Wrapper. Contains page content --> <div class="content-wrapper"> <div class="container-full"> <!-- Main content --> <section class="content"> <div class="box"> <div class="box-header with-border"> <h4 class="box-title">Edit Sub Category</h4> </div> <!-- /.box-header --> <div class="box-body"> <form role="form" method="POST" enctype="multipart/form-data"> <!-- text input --> <div class="form-group"> <label class="form-label">Id</label> <input type="text" class="form-control" name="id" value="<?php echo $fetch['id'];?>" readonly> </div> <div class="form-group"> <label class="form-label">Meta Title</label> <input type="text" class="form-control" value="<?php echo $fetch['meta_title'];?>" name="metatitle" required> </div> <div class="form-group"> <label class="form-label">Meta Description</label> <input type="text" class="form-control" value="<?php echo $fetch['meta_description'];?>" name="metadesc" required maxlength="180"> </div> <div class="form-group"> <label class="form-label">Meta Keywords</label> <input type="text" class="form-control" value="<?php echo $fetch['meta_keywords'];?>" name="metakey" required> </div> <!--<div class="form-group">--> <!-- <label class="form-label">Canonical URL</label>--> <!-- <input type="text" class="form-control" placeholder="Enter ..." name="canonicalurl" required>--> <!--</div>--> <div class="form-group"> <label class="form-label">Category</label> <select class="form-control" name="addcategory" required> <?php $catdata = mysqli_query($conn,"select * from category"); while ($row = mysqli_fetch_assoc($catdata)) { ?> <option <?php echo $fetch['category'] == $row['id'] ? "selected" : ""; ?> value="<?php echo $row['id']; ?>" ><?php echo $row['categoryName']; ?></option> <?php }?> </select> </div> <div class="form-group"> <label class="form-label">SKU</label> <input type="text" class="form-control" value="<?php echo $fetch['sku'];?>" name="sku" required> </div> <div class="form-group"> <label class="form-label">Product Name/Title</label> <input type="text" class="form-control" value="<?php echo $fetch['title'];?>" name="title" required> </div> <div class="form-group"> <label class="form-label">Description</label> <textarea name="desc" id="editor"><?php echo $fetch['description'];?></textarea> </div> <div class="form-group"> <label class="form-label">Additional Information</label> <textarea name="additional" id="editor2"><?php echo $fetch['additional_info'];?></textarea> </div> <div class="form-group"> <label class="form-label">Image</label> <input type="file" class="form-control" accept="image/png, image/jpeg, image/jpg" name="image" onchange="ShowImage(event)" > <img src='<?php echo $fetch['image'];?>' value="" width="200" id="image" /> </div> <div class="box-footer"> <button type="submit" class="btn btn-success" name="update">Update</button> </div> </form> <div class="error"><?php if(!empty($msg)){ echo $msg; } ?></div> </div> <!-- /.box-body --> </div> </div> <!-- /.box-body --> </div> </section> <!-- /.content --> </div> </div> <script src="//cdn.ckeditor.com/4.22.1/standard/ckeditor.js"></script> <script> CKEDITOR.replace( 'editor'); </script> <script> CKEDITOR.replace( 'editor2'); </script> <?php include('include/footer.php');?>