Jump to content

I need help with a simple code... "im a beginner"


evank3

Recommended Posts

Hello, and I am trying to create a language filter that I can have people submit from a form.
I am very new to PHP so I know this is probably a really easy thing to do.

Here are my codes so far:

add_filter.php
[code]<form action="filter_write.php" method="post">
Enter your blocked word: <input type="text" name="word" />
<input type="submit" />
</form>[/code]

filter_write.php
[code]<?php
$word = '$_POST["name"]';
$file = fopen("filter.txt", "a");
fwrite($file, $word);
fclose($file);
?>[/code]

filter.php
[code]<?php
function language_filter($string) {
    $obscenities = @file("filter.txt");
    foreach ($obscenities as $curse_word) {
        if (stristr(trim($string),$curse_word)) {
            $length = strlen($curse_word);
            for ($i = 1; $i <= $length; $i++) {
                $stars .= "*";
            }
            $string = eregi_replace($curse_word,$stars,trim($string));
            $stars = "";
        }
    }
    return $string;
}
?> [/code]

Then filter.txt is blank

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.