Chris E. wrote this and I don't understand: I am trying to have it look up these bad words and if it finds one then reprint the page if it doesnt find a word in the list then place in db. I am good until it comes to actually placing it in a page. Can anyone make a real simple form that has me type a message and this function will run? Can anyone please help me? Thanks!
Chad
----Sorry Had To Make A New Post------
There are many ways to do this but here's one. You can build a function that checks a variable for bad words and returns false if there are any:
function checkBadWords($text) {
$badWords = array('badword1', 'badword2', 'badword3');
foreach ($badWords as $badWord) {
if (ereg($badWord, $text)) {
return false;
}
}
return true;
}
You can call the funtion in your error checking like this:
if (!checkBadWords($message)) {
// re-print the form
}
So if the function returns false then you want to re-print the form. Otherwise you process it.
--------Thanks Chris E.!!!-----