making a list to ban Guest Book entries.

Hello. I am trying to write a code to filter entries (porn and
medical, etc) in my guest book. The words will come in the $comments
field.
This is the file that handles the data coming from the guestbook.php
screen. I don't know how to make it work properly. Any help would be
appreciated. Thank you.

$TableName="banned_words";
$Query="SELECT * FROM $TableName";
$Result=mysql_db_query ($DBName, $Query, $Link);
while ($Row=mysql_fetch_array ($Result))
{
$banned_words[]=$Row[banned_word];
}
$banned_word_count=count($banned_words);

$i=0;
// now loop through the list of banned words ;
for ($i=0; $i<=$banned_word_count; $i++)
{
// to check if the banned word is in the comments ;
if (strstr($banned_words[$i], $comments) !=0)
{
header("location:guestbook.php");
exit();
}
}
joboils [ Do, 15 Juni 2006 15:35 ] [ ID #1356829 ]

Re: making a list to ban Guest Book entries.

Post removed (X-No-Archive: yes)
Notifier Deamon [ Do, 15 Juni 2006 22:43 ] [ ID #1356836 ]

Re: making a list to ban Guest Book entries.

On 15 Jun 2006 13:43:16 -0700, Ralphie <r_sanchez87 [at] yahoo.com> wrote:

>On Thu, 15 Jun 2006 13:35:44 GMT, joboils [at] spam_less_hotmail.com wrote...
>>
>>Hello. I am trying to write a code to filter entries (porn and
>>medical, etc) in my guest book. The words will come in the $comments
>>field.
>>This is the file that handles the data coming from the guestbook.php
>>screen. I don't know how to make it work properly. Any help would be
>>appreciated. Thank you.
>>
>>$TableName="banned_words";
>>$Query="SELECT * FROM $TableName";
>>$Result=mysql_db_query ($DBName, $Query, $Link);
>>while ($Row=mysql_fetch_array ($Result))
>>{
>>$banned_words[]=$Row[banned_word];
>>}
>>$banned_word_count=count($banned_words);
>>
>>$i=0;
>>// now loop through the list of banned words ;
>>for ($i=0; $i<=$banned_word_count; $i++)
>>{
>>// to check if the banned word is in the comments ;
>>if (strstr($banned_words[$i], $comments) !=0)
>>{
>>header("location:guestbook.php");
>>exit();
>>}
>>}
>>
>
>Probably a couple of ways you could tackle that. If you're trying to sanitize
>the "$comments" variable the str_replace function may work for you. As an
>example...
>
>$newtext = str_replace($banned_words, "**censored**", $comments);
>
>You'd still need to build the $banned_words array like you had in your example.
>
>Ralphie
No, I'm not trying to replace anything. If a $comments coing in fro
the public Guest Book screen contains any banned word, I want the
script to ignore it totally.
Is there anything actually wrong with my code?
joboils [ Fr, 16 Juni 2006 02:01 ] [ ID #1358207 ]

Re: making a list to ban Guest Book entries.

joboils [at] spam_less_hotmail.com wrote:
> $banned_words[]=$Row[banned_word];

It must be :
$banned_words[]=$Row["banned_word"];

Hope that work.

--
http://blog.deshot.com
http://www.immersivelounge.com
lorento [ Mo, 19 Juni 2006 15:03 ] [ ID #1361407 ]
PHP » alt.php.sql » making a list to ban Guest Book entries.

Vorheriges Thema: checkbox handling
Nächstes Thema: want rows in 2nd (joined) table listed as columns with 1st