Files
edu/admin/bbs/update_offer.php
T

33 lines
1.2 KiB
PHP

<?php
require_once __DIR__ . '/../../bbs/db_conn.php';
header('Content-Type: application/json; charset=utf-8');
try {
$pdo = db_conn();
$input = json_decode(file_get_contents('php://input'), true);
$offer_id = $input['offer_id'] ?? '';
$status_code = $input['status_code'] ?? '';
$reason_return = $input['reason_return'] ?? '';
if (!$offer_id || !$status_code) {
echo json_encode(['success' => false, 'message' => '필수 파라미터가 누락되었습니다.'], JSON_UNESCAPED_UNICODE);
exit;
}
$sql = "UPDATE edu_content_offer SET status_code = ?, reason_return = ? WHERE offer_id = ?";
$stmt = $pdo->prepare($sql);
$stmt->execute([$status_code, $reason_return, $offer_id]);
if ($stmt->rowCount() > 0) {
echo json_encode(['success' => true], JSON_UNESCAPED_UNICODE);
} else {
echo json_encode(['success' => false, 'message' => '업데이트된 행이 없습니다.'], JSON_UNESCAPED_UNICODE);
}
} catch (Exception $e) {
error_log('[UPDATE_OFFER ERROR] ' . $e->getMessage());
echo json_encode(['success' => false, 'message' => '서버 오류가 발생했습니다.'], JSON_UNESCAPED_UNICODE);
}
?>