Jump to content


Need help with a Userid Filter

  • Please log in to reply
No replies to this topic

#1 oracle259

  • Members
  • PipPipPip
  • Advanced Member
  • 119 posts

Posted 23 September 2006 - 06:13 PM

Basically, i'm writing a function that would check a userid for profanity similar to msn and yahoo userid filters so for example f-shit.4m would not be accepted as a proper userid (also userids must start with a letter and can only contain letters, numbers, hyphens, underscores and dots). Anyway, the banned words would be stored in a mysql database and userid passed by the form would be checked against it. The problem is i need to know if im on the right track with the following code:

$sql = "SEARCH profanity FROM filter";
$result = @mysql_query($sql);
while ($words = @mysql_fetch_array($result, MYSQL_BOTH) {
$profanity[] = $words[profanity];
$kill_characters = array ('.', '-', '_');
$kill_num = range(0,9);
$kill_all = array_merge($kill_num, $kill_characters);

$userid = str_replace($kill_all, '' ", $userid);

$obscene = $profanity[];
foreach ($obscene as $obscenities) {
if (stristr(trim($userid), $obscenities)) {
  $match = similar_text($userid, $obscenities, $percent);
  $percent = round($percent, 2);
  if ($percent >= '50') {
   echo "Sorry, username $userid is too vulgar. Please select another username.";
} else {
echo "Congratulations, username $userid is available.";
} else {
echo "Congratulations, username $userid is available.";


Where am i going wrong?   ???

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users