if ($action == 'update_post') { $post_id = $_POST['post_id']; $aku_id = $_POST['aku_id']; $content = $_POST['content']; $image_url = $_POST['old_image_url'] ?? null; // Logika upload foto baru jika ada if (isset($_FILES['image'])) { $target_dir = "../uploads/posts/"; $new_file = time() . ".webp"; if (move_uploaded_file($_FILES["image"]["tmp_name"], $target_dir . $new_file)) { $image_url = "https://sdksantamaria.sch.id/kancan/uploads/posts/" . $new_file; } } // QUERY UTAMA UPDATE $stmt = $conn->prepare("UPDATE postingan SET content = ?, image_url = ? WHERE post_id = ? AND aku_id = ?"); $stmt->bind_param("ssii", $content, $image_url, $post_id, $aku_id); if ($stmt->execute()) { echo json_encode(["success" => true, "message" => "Berhasil"]); } else { echo json_encode(["success" => false, "message" => $conn->error]); } exit; }