D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home2
/
technoi4
/
www
/
demo
/
admin
/
Filename :
edit_brand.php
back
Copy
<?php require_once('header.php'); require('config.php'); ?> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Update Brand</title> </head> <?php include('sidebar.php'); ?> <!-- sidebar-wrapper --> <main class="page-content"> <div class="container"> <?php $ii = $_GET['id']; $query = "SELECT brand.*, categary.id, categary.categary_title FROM `brand` LEFT JOIN categary ON brand.cid=categary.id where brand.id=$ii"; $res = mysqli_query($conn, $query); $data = mysqli_fetch_assoc($res); mysqli_error($conn); ?> <form method="post" enctype="multipart/form-data"> <div class="row"> <div class="col-md-12"> <input type="hidden" name="oi" value="<?php echo $ii; ?>"> <div> <img src="img/brand/<?php echo $data['image']; ?>" alt="" height="200px" width="200px"> </div> <div class="form-group"> <label for="exampleI">Brand Name</label> <input type="text" class="form-control" name="brand_name" value="<?php echo $data['brand_name']; ?>"> </div> <div class="form-group"> <label for="exampleInputPassword1">Categary_Name</label> <select class="form-control" name="cid"> <option value="<?php echo $data['cid']; ?>"> <?php echo $data["categary_title"]; ?> </option> <option value="">Select Categary_Name</option> <?php require('config.php'); $result = mysqli_query($conn,"SELECT * FROM categary"); while($row = mysqli_fetch_array($result)) { ?> <option value="<?php echo $row['id'];?>"><?php echo $row["categary_title"];?></option> <?php } ?> </select> </div> <div class="form-group"> <label for="exampleI">Description</label> <textarea class="form-control" id="editor" name="brand_desc"><?php echo $data['brand_desc']; ?></textarea> </div> <div class="form-group"> <label for="exampleFormControlFile1">Upload Image</label> <input type="file" class="form-control-file" id="exampleFormControlFile1" name="newimg"> </div> </div> </div> <button name="update" class="btn btn-primary">Update</button> </form> <script> $('#selector').change(function(){ if($(this).val() == "no" ){ $('.otherprof').slideUp(); }else{ $('.otherprof').slideDown(); } }); </script> <script> $('#selector_new').change(function(){ if($(this).val() == "no" ){ $('.other_prof').slideUp(); }else{ $('.other_prof').slideDown(); } }); </script> <?php if (isset($_POST['update'])) { $oi = $_POST['oi']; $brand_name = $_POST['brand_name']; $cid = $_POST['cid']; $brand_desc = addslashes($_POST['brand_desc']); $newimg = $_FILES['newimg']['name']; if (!empty($newimg) && isset($newimg)!=NULL) { $dir = 'img/brand/'; $extension = array("jpeg", "jpg", "png", "gif", "JPG"); $ext = pathinfo($_FILES["newimg"]["name"], PATHINFO_EXTENSION); $newimg = $_FILES['newimg']['name']; require('config.php'); if (in_array($ext, $extension)) { $query = "UPDATE `brand` SET `brand_name`='$brand_name', `cid`='$cid', `brand_desc`='$brand_desc', `image`='$newimg' where id='$oi'"; $res = mysqli_query($conn, $query); if ($res) { move_uploaded_file($_FILES['newimg']['tmp_name'], "$dir" . $newimg); echo '<script type="text/JavaScript"> window.location="brand.php"</script>'; } else echo "eror = " . mysqli_error($conn); } else { echo "Please, Select the file from the following extension: jpeg, jpg, png, gif"; } } else { $query = "UPDATE `brand` SET `brand_name`='$brand_name', `cid`='$cid', `brand_desc`='$brand_desc' where id='$oi'"; $res = mysqli_query($conn, $query); if ($res) { echo '<script type="text/JavaScript"> window.location="brand.php"</script>'; } } } ?> </div> </main> <!-- page-content" --> <?php include('footer.php'); ?>