'Method not allowed']); exit; } try { $data = json_decode(file_get_contents('php://input'), true); if (!isset($data['id'])) { http_response_code(400); echo json_encode(['error' => 'Missing required field: id']); exit; } $id = (int)$data['id']; $db = getDB(); $existing = getNeedPointWithMasjid($db, $id); if (!$existing) { http_response_code(404); echo json_encode(['error' => 'Need point not found']); exit; } $current = (int)($existing['is_verified'] ?? 0); $next = $current === 1 ? 0 : 1; $stmt = $db->prepare('UPDATE need_points SET is_verified = ?, updated_at = CURRENT_TIMESTAMP WHERE id = ?'); $stmt->execute([$next, $id]); $updated = getNeedPointWithMasjid($db, $id); echo json_encode([ 'success' => true, 'point' => $updated ]); } catch (Exception $e) { http_response_code(500); echo json_encode(['error' => $e->getMessage()]); } ?>