Re: Verifying against a file
| From: | Richard Lynch | Date: | Mon, 22 Jan 2001 02:08:46 +0000 |
| Subject: | Re: Verifying against a file | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-35934@lists.php.net to get a copy of this message | ||
> $fd=fopen("words.txt", "r");
Check that $fd is not 0.
> $words = fread($fd, 1000000);
>
> I then convert a string which is passed in a form to this script
>
> $FirstName=strtolower("$FirstName");
>
> And now I check to see if the lowercase version of $FirstName contains any
of
> the words from the $words
>
> if ($FirstName=="$words")
> {
> echo "Bad";
> }
>
> But it doesn`t seem to want to work, anyone give me a pointer as to where
I
> am going wrong with this??
What you have will work only if the file has *EXACTLY* the lower-case of the
$FirstName, with no newlines, and no other names in the file, and the one in
the file must not be Mixed Case.
You are probably looking for something more like this:
if (stristr($words, $FirstName)){
echo "Bad";
}
http://php.net/stristr