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 3 of 3
  1. #1
    Senior Coder
    Join Date
    May 2004
    Posts
    1,466
    Thanks
    15
    Thanked 0 Times in 0 Posts

    check for bad words

    can someone help me with the following --

    I want to loop through all the fields from the form collection and then check through a list of words (badwords) and if any of those words exist in the form then to set a variable $filtered=1

  • #2
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,174
    Thanks
    19
    Thanked 66 Times in 65 Posts
    PHP Code:
    $filtered=0;
    $badwords = array("feck""arse""boobs");
    foreach(
    $_POST as $val)
    {
     foreach(
    $badwords as $swear)
      {
        if(
    strpos($val$badwords)!==false)
         {
            
    $filtered=1;
             return;
         }
       }

    or something similar

  • #3
    Senior Coder
    Join Date
    May 2004
    Posts
    1,466
    Thanks
    15
    Thanked 0 Times in 0 Posts
    does not seem to be working properly.
    shouldn't this take out any word in the form? (regardless of wether there is a space before and after?)
    also how can I make it not case sensitive?


  •  

    Posting Permissions

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