Jump to content

Check if Input Field Contains *insert text here*


Joshua F

Recommended Posts

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.

Archived

This topic is now archived and is closed to further replies.

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