php bad word filter--Get rid of Hateful Words - Web Development and Web Design Codes

Latest

Thursday, February 22, 2018

php bad word filter--Get rid of Hateful Words

php bad word filter

php bad word filter--Get rid of Hateful Words
php bad word filter--Get rid of Hateful Words
Hi friends today we are going to learn nice php script called php bad words filter...
you can stop user to use bad words..you also ban user to advertise their website domain...
php example : php word filter:
<font color="green"><b>PHP Words Filter</b></font>
<form method="post">
<font color="orange"><b><i>Your Content:</i></b></font><br/>
<textarea name="name" rows="8" cols="30" placeholder="Ex: fear,anger,love,good,bad,name,you,your..."/></textarea><br/>
<input type="submit" name="submit" value="Check"/>
</form>
<?php
//Lists Of Filtered Words here
$words=array('FEAR','ANGER','LOVE','GOOD','BAD','NAME','YOU','YOUR','DOG','CAT','HELLO','GO','OUT');
if(isset($_POST['submit'])){

if(!empty($_POST['name'])){
 $total=str_word_count($_POST['name']);
  $inputname=strtoupper($_POST['name']);
  $name=explode(' ',$inputname);

   if(array_intersect($words,$name)){
    $wordarray=array_intersect($words,$name);
    foreach($wordarray as $row){
     echo '<font color=red><b>('.$row.')</b></font> | ';  
    }
  if(count($wordarray)==1){
   echo 'is Restricted Word';
  }else{
   echo 'are Restricted Words';
  }
    
  }else{
   echo '<font color=green><b>Thank Your Article Does not Contain Harmful Words</b></font> ';
  }
} 
}
?>

That's It...
$words=array('FEAR','ANGER','LOVE','GOOD','BAD','NAME','YOU','YOUR','DOG','CAT','HELLO','GO','OUT');

put Your Restricted words in array..note: words must be uppercase..
That's it Friends How to bad word filter using php..Keep visiting ..Thank You..

No comments:

Post a Comment

Thank You for Your Comment

Note: Only a member of this blog may post a comment.