Filter input based on white list.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
TonsOfFun
Forum Commoner
Posts: 54
Joined: Wed Jun 02, 2010 7:37 pm

Filter input based on white list.

Post by TonsOfFun »

Here is my situation,
I have a form input. I want people to be able to use some HTML tags, ie img, strong, h1, etc. but I want to filter out dangerous tags, ie script etc.
Basically I want people to be able to use certain tags that are not potentially harmful.

What is the best way to do this?

Thanks.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Filter input based on white list.

Post by Celauran »

strip_tags() will allow tags you specify and strip out the remainder.
TonsOfFun
Forum Commoner
Posts: 54
Joined: Wed Jun 02, 2010 7:37 pm

Re: Filter input based on white list.

Post by TonsOfFun »

Perfect. Thank you.
Post Reply