evank3 Posted November 22, 2006 Share Posted November 22, 2006 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 Link to comment https://forums.phpfreaks.com/topic/28050-i-need-help-with-a-simple-code-im-a-beginner/ Share on other sites More sharing options...
evank3 Posted November 22, 2006 Author Share Posted November 22, 2006 Would it help if i changed filter_write.php to this[code]<?php$file = fopen("filter.txt", "a");fwrite($file, $_POST["name"]);fclose($file);?>[/code] Link to comment https://forums.phpfreaks.com/topic/28050-i-need-help-with-a-simple-code-im-a-beginner/#findComment-128325 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.