I'm currently learning php and as a challenge, I'm creating a login script using text files to store the information (until I learn how to handle databases with php). The problem I'm having is the if statement in my while loop is only evaluated on the last iteration of the while loop, so its only comparing the last username in the file and no others. Heres the code: <?php session_start(); $users = file("../inc/users.inc.php"); if($_POST['username'] && $_POST['password']){ if(ereg("^[^@ ]+@[^@ ]+\.[^@ \.]+$", $_POST['username'])){ while(list($id ,$username) = each($users)){ if($_POST['username'] == $username){ $_SESSION['logged_in'] = 1; $_SESSION['username'] = $username; } } if($_SESSION['logged_in'] != 1){ $error = "2"; } }else{ $error = "4"; } }else{ $error = "3"; } if($error){ header("Location: http://koopasforever.com/scripts/login.php?error=$error"); }else{ header("Location: http://koopasforever.com/"); } ?> I have checked all my variables and they all contain the proper information Some help would be greatly appriciated, Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php