You can use ereg_* functions to do this.
ex:
if (ereg("sex",$message)) {
echo "Whow this is a bad word";
} else {
...
}
You could create an array of bad word and test the regular expression against the message if it return true then there's a bad word.
ex:
$badword=array("sex","drug");
// Build the regex by concatening array with |
$forbidden="(".implode("|",$badword).")";
if (ereg($forbidden,$message)) {
echo "Whow there is a bad word in your message";
} else {
...
}
But in this case you don't know which which word was the bad word.
To know this you must do the test for each element of the array
hth
JBL