K
K
Kirr072021-04-17 19:29:20
PHP
Kirr07, 2021-04-17 19:29:20

How to format the entered text in the database?

There is a form with which the user changes the base text and then it is displayed on the page. How to arrange it beautifully?
I can keep the custom formatting, but the problem is that the text itself is there <img src="">and then there will be no picture, only the tag will remain. Initially, everything in the database was tagged, but I don't think that's good.
Are there any other options?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yupiter7575, 2021-04-17
@yupiter7575

Let's say you have a page with textarea, the user enters the formatting <.i>, <.b>, etc. there. Clicks on the button and the form is sent to the php handler:

$text = $_GET['text'];
$text = strip_tags($text, '<i><b>');

strip tags removes all tags from the first argument, the second argument is the tags that should not be removed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question