For some reason, basic logic doesn’t work with this code…
I am making a very simple(and somewhat poor) chat system. Anyways, I am trying to implement a way so that the same user can not log on twice, which will prevent other problems, including logging off issues.
This is the only part that doesn’t work. It opens the user list file and reads it line by line. The file has one user per line. But for some reason, even if the line that is read equals(exactly) the users name, then it will still not exit and pretends that the two do not match and so the two users can log on with the same name.
[code=php]
$currentUserList = fopen($user_file, “r”) or exit(“Unable to open file!”);
while(!feof($currentUserList))
{
$tmpUser = fgets($currentUserList);
if($tmpUser == $getName)
{
exit(‘name taken’);
}
}
I have echoed the code back and seen that the two values are indeed equal, but yet the code does not exit, and so the script continues on to log in the user.
Does anyone have any ideas? I’ve tried this several ways, and none of them have worked yet.
I really would like to keep any methods simple.