...

View Full Version : html filtering



Arragon
01-25-2007, 09:27 PM
Does anyone know of a PHP function or class that will take user input and strip out all html tags except the A tags, IMG tags or others that I permit?

I am working on a simple bulletin board type system and I want to allow users to post links and images, but not scripts, tables or other things I deem unworthy.

Such code must surly exist. I am hoping to not spend time re-inventing the wheel here.

JohnDubya
01-25-2007, 10:16 PM
Does anyone know of a PHP function or class that will take user input and strip out all html tags except the A tags, IMG tags or others that I permit?


strip_tags() is what you're looking for. Read about it here: http://us2.php.net/strip_tags

As you can see, in the optional second parameter, you can specify which tags you want the function to leave alone. Good luck!

Arragon
01-25-2007, 10:17 PM
*smacks self on forehead and wanders off muttering something about RTFM*

Thanks

JohnDubya
01-25-2007, 11:04 PM
*smacks self on forehead and wanders off muttering something about RTFM*

Thanks

LOL.......had to look up the meaning of RTFM...and I laughed. :D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum