Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

EbrahemSamer's avatar

How to sanitize html content from database ? PHP Native

I am using trix editor to insert text in database and I am inserting data without filtering .. because filter data is removing the html content and I need this .....

How to make this process secure, I mean How to insert data in database with html in secure approch.

And how to get it back in secure

` // was using this but skip html

$title_ar = filter_input(INPUT_POST, 'title_ar', FILTER_SANITIZE_STRING);
$title_en = filter_input(INPUT_POST, 'title_en', FILTER_SANITIZE_STRING);

// now using this but not secure.

$desc_ar = addslashes($_POST['desc_ar']);
$desc_en = addslashes($_POST['desc_en']);

`

0 likes
2 replies

Please or to participate in this conversation.