Joshua F Posted May 1, 2011 Share Posted May 1, 2011 I have a register script, and I am wanting to make it so that if the username field contains, lets say "mod", "ass", and more, then it'll return an error and wont let them register. Quote Link to comment Share on other sites More sharing options...
PaulRyan Posted May 1, 2011 Share Posted May 1, 2011 Try the following, just place the banned words in the $bannedWords array... <?PHP $username = 'Peter Ass'; $bannedWords = array('ass','poop','admin','mod','team','staff'); if(preg_match('#('.implode('|',$bannedWords).')#i', $username)) { echo 'Failed'; } else { echo 'Passed'; } ?> Try it out and let me know how it goes. Regards, PaulRyan. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.