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.
lldcrb328 0
Newbie Poster
Recommended Answers
Jump to PostTry something along the lines of the following:
<? $file='file.txt'; //set the file name and path $lines=explode(' ',file_get_contents($file)); foreach ($lines AS $line) { if ($_POST['username']==$line) { $userfound='true'; break; } } if ($userfound=='true') { //script for if user is found in text file } ?>
Although the above …
Jump to PostA sample preg_match script:
$userfound = (preg_match("/\b$username\b/") === 1);
All 5 Replies
cwarn23 387
Occupation: Genius Team Colleague Featured Poster
death_oclock 103
Posting Whiz
UHussain 0
Newbie Poster
death_oclock 103
Posting Whiz
cwarn23 387
Occupation: Genius Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.