📁 File Manager
🏠 /
/
home
/
u857492117
/
domains
/
mangaldailawcollege.in
/
public_html
/
law-admin
Dosya Düzenle: update_notice.php
<?php session_start(); if (!isset($_SESSION['admin'])) { header("Location: login.php"); exit; } require 'config/db.php'; $id = (int)$_POST['id']; $title = trim($_POST['title']); $category = trim($_POST['category']); $description = trim($_POST['description']); $publish_date = $_POST['publish_date']; $status = $_POST['status']; $external_link = trim($_POST['external_link']); $image = $_POST['old_image']; $document = $_POST['old_document']; /* ----------------------- Upload New Image ------------------------ */ if (!empty($_FILES['image']['name'])) { $allowed = ['jpg','jpeg','png','webp']; $ext = strtolower(pathinfo($_FILES['image']['name'], PATHINFO_EXTENSION)); if (!in_array($ext,$allowed)) { die("Invalid image format."); } if ($image && file_exists("uploads/notices/images/".$image)) { unlink("uploads/notices/images/".$image); } $image = time()."_".uniqid().".".$ext; move_uploaded_file( $_FILES['image']['tmp_name'], "uploads/notices/images/".$image ); } /* ----------------------- Upload New Document ------------------------ */ if (!empty($_FILES['document']['name'])) { $allowed = ['pdf','doc','docx']; $ext = strtolower(pathinfo($_FILES['document']['name'], PATHINFO_EXTENSION)); if (!in_array($ext,$allowed)) { die("Invalid document."); } if ($document && file_exists("uploads/notices/documents/".$document)) { unlink("uploads/notices/documents/".$document); } $document = time()."_".uniqid().".".$ext; move_uploaded_file( $_FILES['document']['tmp_name'], "uploads/notices/documents/".$document ); } /* ----------------------- Update Database ------------------------ */ $sql = $conn->prepare(" UPDATE notices SET title=?, category=?, description=?, image=?, document=?, external_link=?, status=?, publish_date=? WHERE id=? "); $sql->execute([ $title, $category, $description, $image, $document, $external_link, $status, $publish_date, $id ]); header("Location: notices.php?updated=1"); exit; ?>
💾 Kaydet
İptal