%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/www/website_7c8ed5ef/admin/manage_projects/ |
Upload File : |
<?php
error_reporting(0);
include("../function.php");
if($_SESSION['admin_id']==""){
header('location:../login.php');
}
$service_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 Projects</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 project_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="heading">Heading</label>
<input type="text" name="heading" class="form-control" value="<?php if($id!=''){ echo $fetchData['heading']; }?>">
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<label class="form-label" for="description">Description</label>
<textarea name="description" class="form-control"><?php if($id!=''){ echo $fetchData['description']; } ?></textarea>
</div>
</div>
<div class="gap-2" id="input-container">
<div class="row">
<div class="col-lg-10">
<h5>Content Atb</h5>
<textarea rows="3" name="content1_atb" class="form-control" id="content_atb"><?php if($id!=''){ echo $fetchData['content1_atb']; } ?></textarea>
</div>
<div class="col-lg-2">
<h5>Add Content Atb</h5>
<a id="myButton" class="bg-success form-control text-center text-white fw-bold mt-1 mb-2">Add More</a>
</div>
</div>
</div>
<!-- Muliple Product images color etc start edit --->
<?php
$attribute=mysqli_query($conn,"SELECT * FROM `project_content_atb_tbl` WHERE project_id='".$_REQUEST['id']."'");
if(mysqli_num_rows($attribute)>0){ ?>
<?php
$Atb=mysqli_query($conn,"SELECT * FROM `project_content_atb_tbl` WHERE project_id='".$_REQUEST['id']."'");
while($row=mysqli_fetch_array($Atb)){ ?>
<div class="form-group input-element data-item">
<input type="hidden" name="id_editatb[]" class="form-control" required value="<?=$row['id']?>" >
<div class="row">
<div class="col-lg-10">
<h4>Content Atb</h4>
<textarea name="content_edit_atb[]" class="form-control" rows="3"><?=$row["content_atb"];?></textarea>
</div>
<div class="col-lg-2 mt-4">
<a class="bg-danger form-control text-center text-white fw-bold delete-btn" data-id="<?=$row['id']?>">Remove</a>
</div>
</div>
</div>
<?php } ;?>
<?php } else { ?>
<?php } ?>
<!-- Muliple Product images color etc wrap edit --->
<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/Projects/'.$fetchData['image1'].'" 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=service">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>
<script>
$(document).ready(function() {
$("#myButton").click(function() {
$.ajax({
url: "insert_input.php",
success: function(html) {
$("#input-container").append(html);
}
});
});
});
$(document).on("click", ".remove-input", function() {
$(this).closest(".input-element").remove();
});
$(document).ready(function() {
$('.delete-btn').on('click', function() {
var itemId = $(this).data('id');
var deleteButton = $(this);
$.ajax({
url: 'delete_product.php',
method: 'POST',
data: { id: itemId },
success: function(response) {
// Handle the response from the server
console.log(response);
// Remove the deleted data from the DOM
deleteButton.closest('.data-item').remove();
},
error: function(xhr, status, error) {
// Handle the error
console.log(error);
}
});
});
});
</script>
<?php
if (isset($_POST['edit'])) {
$title=$_POST['title'];
$title=str_replace("'", "\'", $title);
$heading=$_POST['heading'];
$heading=str_replace("'","\'",$heading);
$description=$_POST['description'];
$description=str_replace("'","\'",$description);
$content1_atb=$_POST['content1_atb'];
$content1_atb=str_replace("'","\'",$content1_atb);
$status=$_POST['status'];
$slug = create_url($title) . $_REQUEST['id'];
// 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/Projects/" . $new_file_name;
if (move_uploaded_file($file_tmp, $file_path)) {
$dlt = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM `project_tbl` WHERE id = '" . $_REQUEST['id'] . "'"));
$dlt_path = "../../images/Upload/Projects/" . $dlt['image1'];
if (file_exists($dlt_path)) {
unlink($dlt_path);
}
$sql = mysqli_query($conn, "UPDATE `project_tbl` SET `image1` = '$new_file_name' WHERE id = '" . $_REQUEST['id'] . "'");
}
}
// Update popular_packages_tbl content
mysqli_query($conn, "UPDATE `project_tbl` SET
`title`='$title',
`heading`='$heading',
`description`='$description',
`content1_atb`='$content1_atb',
`slug`='$slug',
`status`='$status' WHERE
`id` = '" . $_REQUEST['id'] . "'");
// Handle updates to about_image_tbl
if (isset($_POST['id_editatb']) && is_array($_POST['id_editatb'])) {
foreach ($_POST['id_editatb'] as $key => $id_editatb) {
$content_editatb = mysqli_real_escape_string($conn, $_POST['content_edit_atb '][$key]);
$updateTitleQuery = "UPDATE `project_content_atb_tbl` SET `content_atb` = '$content_editatb' WHERE id = '$id_editatb'";
mysqli_query($conn, $updateTitleQuery);
}
}
// Handle adding new content to about_image_tbl
if (isset($_POST['content_atb']) && is_array($_POST['content_atb'])) {
foreach ($_POST['content_atb'] as $key => $val) {
// Sanitize the content to prevent SQL injection
$content_atb = mysqli_real_escape_string($conn, $val);
// Insert query
$insertQuery = "INSERT INTO `project_content_atb_tbl` (`project_id`, `content_atb`) VALUES ('" . $_REQUEST['id'] . "', '$content_atb')";
// Execute the query
if (!mysqli_query($conn, $insertQuery)) {
die("Error inserting new image: " . mysqli_error($conn));
}
}
}
echo "<script>window.location='show.php?page=proj';</script>";
$_SESSION['message']="Service Updated successfully";
}
?>