RE: [PHP] Naughty Word Catcher

From: Date: Wed, 31 Jan 2001 06:45:42 +0000
Subject: RE: [PHP] Naughty Word Catcher
Groups: php.general 
Request: Send a blank email to php-general+get-37427@lists.php.net to get a copy of this message
Will work well, I think ... plus this is on submission which makes a little discount on load times. And it is quite expandable function. Cheers, Maxim Maletsky -----Original Message----- From: Chris Aitken [mailto:chris@ideal.net.au] Sent: Wednesday, January 31, 2001 2:04 PM To: php-general@lists.php.net Subject: [PHP] Naughty Word Catcher Hi all, Ive just been asked whether I can do the following task..... When a block of text is submitted via a web form, for it to be checked for offensive words, and rejected if there is. So I put my brain hard to work and came up with a possibly solution. I know this method should work but im wondering if I should tackle it a different way. This is just a rough, typed-off-the-top-of-my-head to show the method rather than correct code. The idea was to have a list of offensive words or phrases in a MySQL database, and the script would take the block of text, and do the following $query="select naughty_words from prude_list"; $result=mysql_query($query); while ($loop=mysql_fetch_array($result)) { $naughty_word_checker = stristr("$block_of_text","$loop[naughty_words]"); if ($naughty_word_checker) { header("Location: error.php?reason=prudes_wont_like_it"); } else { header("Location: insert_stuff.php?comment=$block_of_text"); } } or is there a better, more efficient way of doing it. Im pretty sure the concept of above will work because if there is a match, stristr() should return text, otherwise it shouldnt return anything (or if im wrong, a little fine tuning will sort that out). Thanks Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#37427) next »