Jump to content

Need help with a Userid Filter


oracle259

Recommended Posts

Basically, i'm writing a function that would check a userid for profanity similar to msn and yahoo userid filters so for example [b]f-shit.4m[/b] 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:

<?php
$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?   ???
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.