Jump to content

Checking for banned characters problem


www.mihalism.com
 Share

Recommended Posts

I made a function to check if a name contains banned characters. When the function does check for a banned character it always return false.

	function banned_letters($name){	global $_CONFIG;		for($i=0; $i < strlen($name); $i++){			$pos = strrpos($_CONFIG['allowed_letters'],$name{$i});				if ($pos === false){					return true;				}else{					return false;				}		}	}

Link to comment
Share on other sites

Wow, you are trying wayyy too hard!

function banned_letters($name){$pattern = "/(\!\@\#\$\%\^\&\*\(\))/is";$regex = ereg($pattern, "", $name);if($regex){  return false;}else{  return true;}

That should work, untested though! So you may have to try it. Tell me if it doesnt work.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...