%PDF- %GIF98; %PNG;
Server : ApacheSystem : Linux sh00666.bluehost.com 5.14.0-687.26.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Jul 14 16:32:02 EDT 2026 x86_64 User : ndkhermy ( 1200) PHP Version : 8.5.12 Disable Function : NONE Directory : /home1/ndkhermy/public_html/website_7c8ed5ef/admin/manage_industries/ |
Upload File : |
<?php
error_reporting(0);
include("../function.php");
if ($_SESSION['admin_id'] == "") {
header('location:../login.php');
}
$industries_tbl = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM admin WHERE admin_id='" . $_SESSION['admin_id'] . "'"));
// Sidebar strat
include('../include/sidebar.php');
// Sidebar wrap
$id = $_REQUEST['id'];
// ini_set('display_startup_errors', 1);
// ini_set('display_errors', 1);
// error_reporting(E_ALL);
?>
<!-- [ Main Content ] start -->
<section class="pcoded-main-container">
<div class="pcoded-content">
<!-- [ breadcrumb ] start -->
<div class="page-header">
<div class="page-block">
<div class="row align-items-center">
<div class="col-md-12">
<div class="page-header-title">
<div class="card-header d-flex justify-content-between">
<button class="btn btn-light text-white fw-bold btn-sm btn-round has-ripple"><i class="feather icon-edit"></i> Update Industries</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- [ breadcrumb ] end -->
<!-- [ Main Content ] start -->
<div class="row">
<div class="col-md-12">
<div class="card">
<!-- <div class="card-header d-flex justify-content-between">
</div> -->
<div class="card-body">
<?php if (isset($_SESSION['message'])) {
echo '<div class="alert alert-success alert-dismissible fade show" role="alert">
<i class="feather icon-thumbs-up text-success"></i> <strong class="text-dark">' . $_SESSION['message'] . '</strong>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close">
</button>
</div>';
}
unset($_SESSION['message']);
?>
<?php if (isset($_SESSION['img_error'])) {
echo '<div class="alert alert-danger alert-dismissible fade show" role="alert">
<i class="feather icon-alert-triangle text-danger"></i> <strong class="text-dark">' . $_SESSION['img_error'] . '</strong>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close">
</button>
</div>';
}
unset($_SESSION['img_error']);
?>
<form method="POST" enctype="multipart/form-data" autocomplete="off">
<?php
$fetchData = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM industries_tbl WHERE id='" . $_REQUEST['id'] . "'"));
?>
<div class="container">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="Title">Title </label>
<input type="text" name="title" class="form-control" value="<?php if ($id != '') { echo $fetchData['title']; } ?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="Title">Heading 1</label>
<input type="text" name="heading1" class="form-control" value="<?php if ($id != '') { echo $fetchData['heading1']; } ?>" />
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="Title">Heading 2</label>
<input type="text" name="heading2" class="form-control" value="<?php if ($id != '') { echo $fetchData['heading2']; } ?>" />
</div>
</div>
<div class="col-md-6 mb-2">
<div class="form-group">
<label for="image" class=" form-control-label mb-2">Image</label>
<input type="file" name="image1" class="form-control">
<p id="error1" style="color:red; display:none;">File Must be JPEG,JPG,PNG,SVG</p>
<p id="error2" style="color:red; display:none;">File Must be lessthan 20MB</p>
</div>
<?php if ($id != '') {
echo '<img src="' . $base_url . 'images/Upload/Industries/' . $fetchData['image1'] . '" style="width: 120px; height: 100px;">';
} ?>
</div>
<div class="col-md-6 mb-2">
<div class="form-group">
<label for="image" class=" form-control-label mb-2">Image2</label>
<input type="file" name="image2" class="form-control">
<p id="error1" style="color:red; display:none;">File Must be JPEG,JPG,PNG,SVG</p>
<p id="error2" style="color:red; display:none;">File Must be lessthan 20MB</p>
</div>
<?php if ($id != '') {
echo '<img src="' . $base_url . 'images/Upload/Industries/' . $fetchData['image2'] . '" style="width: 120px; height: 100px;">';
} ?>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="form-label" for="status">Status</label>
<select class="form-select" name="status" required>
<option value="">Please select status</option>
<option value="1" <?= ($fetchData['status'] == 1) ? 'selected' : '' ?>>Show</option>
<option value="0" <?= ($fetchData['status'] == 0) ? 'selected' : '' ?>>Hide</option>
</select>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<button name="edit" type="submit" class="btn btn-success">Update</button>
<a class="text-white btn btn-secondary" href="show.php?page=indusice">Back</a>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<!-- [ form-element ] end -->
</div>
<!-- [ Main Content ] end -->
</div>
</section>
<!-- Required Js -->
<?php include('../include/footer.php'); ?>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<?php
if (isset($_POST['edit'])) {
$title = $_POST['title'];
$title = str_replace("'", "\'", $title);
$heading1 = $_POST['heading1'];
$heading1 = str_replace("'", "\'", $heading1);
$heading2 = $_POST['heading2'];
$heading2 = str_replace("'", "\'", $heading2);
$status = $_POST['status'];
// Handle image update
if (!empty($_FILES['image1']['name'])) {
$file_name = $_FILES['image1']['name'];
$file_tmp = $_FILES['image1']['tmp_name'];
$file_ext = strtolower(end(explode('.', $file_name)));
$random_number = rand(111111111, 999999999);
$new_file_name = $random_number . '.' . $file_ext;
$file_path = "../../images/Upload/Industries/" . $new_file_name;
if (move_uploaded_file($file_tmp, $file_path)) {
$dlt = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM `industries_tbl` WHERE id = '" . $_REQUEST['id'] . "'"));
$dlt_path = "../../images/Upload/Industries/" . $dlt['image1'];
if (file_exists($dlt_path)) {
unlink($dlt_path);
}
$sql = mysqli_query($conn, "UPDATE `industries_tbl` SET `image1` = '$new_file_name' WHERE id = '" . $_REQUEST['id'] . "'");
}
}
if (!empty($_FILES['image2']['name'])) {
$file_name = $_FILES['image2']['name'];
$file_tmp = $_FILES['image2']['tmp_name'];
$file_ext = strtolower(end(explode('.', $file_name)));
$random_number = rand(111111111, 999999999);
$new_file_name = $random_number . '.' . $file_ext;
$file_path = "../../images/Upload/Industries/" . $new_file_name;
if (move_uploaded_file($file_tmp, $file_path)) {
$dlt = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM `industries_tbl` WHERE id = '" . $_REQUEST['id'] . "'"));
$dlt_path = "../../images/Upload/Industries/" . $dlt['image2'];
if (file_exists($dlt_path)) {
unlink($dlt_path);
}
$sql = mysqli_query($conn, "UPDATE `industries_tbl` SET `image2` = '$new_file_name' WHERE id = '" . $_REQUEST['id'] . "'");
}
}
// Update popular_packages_tbl content
mysqli_query($conn, "UPDATE `industries_tbl` SET
`title`='$title',
`heading1`='$heading1',
`heading2`='$heading2',
`status`='$status' WHERE `id` = '" . $_REQUEST['id'] . "'");
echo "<script>window.location='show.php?page=indus';</script>";
$_SESSION['message'] = "Service Updated successfully";
}
?>