Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: html filtering

  1. #1
    New Coder
    Join Date
    Jan 2007
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

    html filtering

    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.

  • #2
    Super Moderator JohnDubya's Avatar
    Join Date
    Nov 2006
    Location
    Missouri
    Posts
    634
    Thanks
    12
    Thanked 18 Times in 18 Posts
    Quote Originally Posted by Arragon View Post
    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!

  • #3
    New Coder
    Join Date
    Jan 2007
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts
    *smacks self on forehead and wanders off muttering something about RTFM*

    Thanks

  • #4
    Super Moderator JohnDubya's Avatar
    Join Date
    Nov 2006
    Location
    Missouri
    Posts
    634
    Thanks
    12
    Thanked 18 Times in 18 Posts
    Quote Originally Posted by Arragon View Post
    *smacks self on forehead and wanders off muttering something about RTFM*

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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •