4000) { $body = substr($body, 0, 4000); } $pdo = db(); $stmt = $pdo->prepare( 'INSERT INTO messages(vendor_id, author, body) VALUES(?, ?, ?)' ); $stmt->execute([$vendor_id, $actor, $body]); $new_id = (int) $pdo->lastInsertId(); header('Content-Type: text/html; charset=utf-8'); header('X-Msg-Id: ' . $new_id); echo render_messages($vendor_id, $new_id - 1);