Results 1 to 5 of 5

Thread: Filter out bad words

  1. #1
    Join Date
    Jan 2007
    Location
    The stage
    Posts
    568
    Thanks
    23
    Thanked 6 Times in 6 Posts

    Default Filter out bad words

    Hey guys I was if it is possible to filter out words before they are posted on the site. It is two bad that the only way I know how to do this is if the user only enters the bad word... I was thinking of using if else statements, but that doesn't work so well.
    I don't know how you can filter out words from a textarea after the form has been submitted... But if you guys wanna see the code I'll post it up...

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,156
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    $bad = array('monkeys','fish','potatoes');
    foreach($bad as $w) {
    $string = str_replace($w,'',$string);
    }
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Jan 2007
    Location
    The stage
    Posts
    568
    Thanks
    23
    Thanked 6 Times in 6 Posts

    Default

    hold on a bit and I'll put the code in... and test it... and reply with the results...

  4. #4
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    Quote Originally Posted by djr33 View Post
    $bad = array('monkeys','fish','potatoes');
    foreach($bad as $w) {
    $string = str_replace($w,'',$string);
    }
    You might want to replace it with something like #@#%%!!, or else it won't make any sense.
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,156
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    It's fun to replace it with weird things.

    Like... 'gagagoogoo!'
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

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