read and if not there write, if there dont write and echo
Posted: Fri Jul 16, 2004 11:59 pm
hey,
text file writing/listing format:

Code: Select all
<?php
$names = file("winners/win06.txt");
if(array_search($_SESSION['username'],$names) !== false) {
echo "<script>alert('Cheaters never win.');</script>";
include("http://blah.com/js02.php");
return;
} else {
$dis = $_SESSION['username'];
$fp = fopen("winners/win06.txt","ab");
fputs($fp, $dis."\n");
fclose($fp);
}
?>ok, I'm trying to mark when a user has already completed a mission, my method is to write there name to a file, one per line, and then when the user tries to cheat by redoing the same mission, the script will find their name in the file and tell them they are cheating and will send them back to the beginning... however this above script is not doing that, it just keeps adding my user name, atleast now it forces line breaks, but it just isn't finding my username, I think it's because this script take the entire file and makes it's enitre contents one big var, I need to have it read each line one at a time, to find out if that users name exists in the list... ive been workin on a fix for a day and half now, and am stumped, any help is appreciated thanksjohn
jason
suzi
jack
charles