Click to See Complete Forum and Search --> : Find and Replace
madddidley
04-19-2004, 11:06 AM
I have a simple guestbook and I am trying to add a little feature to it. I would like to block the toilet words that get submitted. You know those four letter words. If someone could help me that would be great.
www.madddidley.com
crh3675
04-19-2004, 11:49 AM
Create an array of those words:
$badwords=Array("fun","crud","shout","bits");
Then parse your request:
$data=$_GET["data"];
foreach($badwords as $badword){
$data=eregi_replace($badword,"",$data);
}
print $data;
madddidley
04-19-2004, 12:46 PM
Thanks a million
jeant
11-27-2004, 09:07 AM
Is there a way to reject these entries altogether instead of just replacing the bad words? We are getting repeated entries in our guestbook suggesting sites inappropriate for our family oriented website. I would like to keep them out of our guestlog. jeant@angletoncofc.org
Ben Rogers
11-27-2004, 08:18 PM
Maybe something like this?$bad = 0;
foreach ($badwords as $badword) {if (preg_match("/$badword/i", $str)) {$bad = 1;}}
if (!$bad) {
/* post entry */
} else {print "<p><strong>Clean up the language!</strong></p>";}
dreamcatcher
11-28-2004, 02:49 AM
I know the feeling in having junk posted to your guestbook. Its a good idea to be able to approve entries. This does stop the rubbish getting to the guestbook, but unfortunately, doesn`t stop the amount of crap that gets posted.
You could use a security image when people post. This might work as it stops spam software in its tracks.
Check this one out:
http://www.rushtheweb.com/products.php?cmd=FormProtect
LiLcRaZyFuZzY
11-28-2004, 09:21 AM
hey madddidley, you should watch your site http://madddidley.com with Mozilla firefox
Paul Jr
11-28-2004, 09:52 PM
Originally posted by Ben R.
Maybe something like this?$bad = 0;
foreach ($badwords as $badword) {if (preg_match("/$badword/i", $str)) {$bad = 1;}}
if (!$bad) {
/* post entry */
} else {print "<p><strong>Clean up the language!</strong></p>";}
Since you're just checking for the existance of one string inside another, it would be less memory-intensive to use stristr() (http://www.php.net/stristr) (case-insensitive version of strstr() (http://www.php.net/strstr)), or even strpos() (http://www.php.net/strpos).
madddidley
11-29-2004, 12:05 AM
I know. My site is down in the dumps when it comes to the mozilla. I tried to redo my style sheet and said funk that. Giving me too many headaches. So I am just going to create a style sheet for mozilla and switch it up accordingly.
LiLcRaZyFuZzY
11-29-2004, 12:26 AM
;)