read file for names if there die if not write, help???
Posted: Fri Jul 16, 2004 3:05 am
hi,
trying to write a script that opens a txt file and reads it:
if you were to read this file, it would look like this:
johnny
suzi
kelly
Blare
Tony
etc...
that way the script can read each line one at a time... my problem is actually writing something that can do that, and tell the script if it found it, and die if so, else it would write there name in the list, enumerating that info, via session var...
my guess:
thanks 
trying to write a script that opens a txt file and reads it:
if you were to read this file, it would look like this:
johnny
suzi
kelly
Blare
Tony
etc...
that way the script can read each line one at a time... my problem is actually writing something that can do that, and tell the script if it found it, and die if so, else it would write there name in the list, enumerating that info, via session var...
my guess:
Code: Select all
$df = fopen("blah.txt", "a+");
$xf = file_get_contents($df);
if(!xf) {
@fwrite($df,$_SESSION['usernam'] "\n");
@fclose($df);
} else {
echo "You have already done this once!";
@fclose($df);
}