Jump to content

Archived

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

Millar

PHP Help

Recommended Posts

Well, I was wondering if anyone could give me a script I can use to get a entered value from a post form (e.g Username) and check to see if the username exists in a plain txt file I have with usernames separated by a line break, thanks in advanced.
Millar.

Share this post


Link to post
Share on other sites
This should work, assuming that each line is only the username.

[code]$filename = "path/to/file.txt";
$username = $_POST['username'];

$file = file($filename);
if (in_array($username, $file)) {
  ...code for when the username is in the file...
} else {
  ...code for when the username is not in the file...
}[/code]

Share this post


Link to post
Share on other sites

×

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.