Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php - textarea- html tags

Tags:

html

php

textarea

I am new to programming with php. I've done that: There is a textarea that user writes text, and it is saved to db. But when listing the entries, the text with html tags are shown as html elements.

For example, "I'm < b >25< /b > years old" is shown "I'm 25 years old".

I want to show it as what user writes on textarea, not applying html rules. And due to this, user can not break multiple lines.

How can I avoid all html properties? is there any function or something else to help me?

like image 237
user675511 Avatar asked Mar 21 '26 19:03

user675511


1 Answers

Run the posted content through htmlentities:

$var = htmlentities($old_var);

Note: you should also be making sure you're not making yourself vulnerable to SQL injection.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!