Reputation:
I run a niche social network site. I would like to disallow HTML content in user posted messages; such as embedded videos etc. what option is there in php to clean this up before I insert into the db.
Upvotes: 7
Views: 229
Reputation: 72580
There are three basic solutions:
strip_tags()
function.<b>hello</b>
it shows up as <b>hello</b>
in the HTML, or <b>hello</b>
on the page itself. In PHP this is the htmlspecialchars()
function. (Note: in this situation you would generally store the content in the database as-is, and use htmlspecialchars wherever you output the content.)<object>
in your case). You may or may not wish to do this before storing in the database, but you must always do it before output in either case.Upvotes: 14