Ya Fa Su
Ya Fa Su

Reputation: 160

Remove Html Tags from textarea

Is there a way to remove or not allow to put Html tags in a textarea?

I have a form that send email with a textarea where user put comments.

But I got some spammers, putting html code in the textarea, which appear a form of html when the mail is send.

How can I convince that?

Upvotes: 1

Views: 11410

Answers (2)

Quentin
Quentin

Reputation: 943207

It sounds like you are taking input that is supposed to be text, but are treating it as HTML (by injecting it, unchanged, in an HTML document).

Pass the data through htmlspecialchars to create an HTML representation of the entered text (before adding it to the HTML document).

Upvotes: 0

John Conde
John Conde

Reputation: 219804

  1. Use strip_tags()
  2. Use HTML Purifier (recommended)

Upvotes: 1

Related Questions