jquery post – how to send code snippets to mysql database

bstory is a contenteditable div and typing inside – it sends the content to remote database
everything works except – if the content is – for example – session_start – I’m getting error 403 in console
on php side I’m using PDO
inside this table I want to store code snippets from various programming languages, but obviously there is a flag – even if PDO is used

how to do this, pls

$('#bstory').on('input', function(){
    let id = get_id();
    let story = $(this).text().trim();
    $.post('pro.php', {fn: 'bstory_input', args:[id, story]}, function(data){
        console.log(data);  // error
    });
});

php

function bstory_input($id, $story){
    global $db;
    $sq = "update nts set story = :astory where id = :aid";
    $st = $db->prepare($sq);
    $st->execute([
        ":astory" => $story,
        ":aid" => $id
    ]);
}