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. Link to comment https://forums.phpfreaks.com/topic/235248-check-if-input-field-contains-insert-text-here/ 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. Link to comment https://forums.phpfreaks.com/topic/235248-check-if-input-field-contains-insert-text-here/#findComment-1208931 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.