Hey Tony,
I've made a quick script to help you out,
ok firstly you need to create your text file and save it as badwords.txt and then in the same directory create a php file, name it whatever you want.
now add the following line of text to the badwords.txt file:
dog;cat;cow;horse;moose
and save it in the badwords.txt file, make sure there are no whitespaces from the begining and end.
once you have done that copy and paste the php script below into your php file:
<?php
// create a file handler to open the file in read mode only 'r'
$fp = fopen( "badwords.txt", 'r' );
// place all the words into the varible
$badwordsGroup = fread( $fp, 100000 );
// break each word up and place in an array, using ; as the delimeter
$badword = explode(";", $badwordsGroup);
// here is where we test the username supplied to see if its valid
// I have manually set the username to match one of the badwords
$username = "fds"; // you can change this to see different results this stores your users requested username
$isValid = 1;
// go through each badword to see if the username matches it, if it does we set
// the $isValid flag to 0.
foreach ($badword as $value)
{
if($username == $value)
{$isValid = 0;}
}
// if a bad word matched the username, the $isValid flag would of been set to 0,
// so here we test it, if it is 0 then the user has an invalid name.
if($isValid == 0)
{ echo "sorry please pick another username";}
?>
ok for this demo, I;ve used animal names as badwords, you can continue to add whatever blocked words you want to the txt file, but remember that in between every word you must put in a SEMICOLON to seperate it.
Once this is all working for you, you can see from the code how its done and hopefully incorporate it into your project.