Forum Moderators: coopster
$blockwords="badword 1, badword 2, badword 3,";
if(!empty($blockwords)&&!empty($_POST)){$useBlocks=explode(",",$blockwords);foreach($useBlocks as $blockWord){foreach($_POST as $Name=>$Value){$Value=trim($Value);$Value=strtolower($Value);if(!empty($Value)&&strpos($Value,$blockWord)!==false){exit("--B L O C K E D-- .You used a bad word.");}}}}
-----------------------------------------------------------------
The code works but it comes with warnings... any idea of how to get rid/fix of the warning? I have googled the warning but all i get are pages with an actual live warning/error
-----------------------------------------------------------------
here's the warning:
Warning: strpos() [function.strpos]: Empty delimiter in /home/site/public_html/website/form/post.php on line 15
Something like the following will fix it:
foreach($useBlocks as $blockWord)
{
if($blockword)
{
// Rest of code is as before
}
}
By the way... It's much easier to read code (especially other people's code) when it's well spaced and not all on one line... :)
after:
$blockwords="badword 1, badword 2, badword 3";
...that is the only difference that I can see between my correction, but I do not have a trained eye.
anyways the problem is fixed but I will copy and paste your suggestion to my hard drive for future reference