meltingpoint Posted June 22, 2009 Share Posted June 22, 2009 In the code below I want to query a flat file and put string contents into list. Then check if the username supplied from the form matches $member in the list. It works fine if one person is in the database- but not if there are two or more. What am I doing wrong? I have in the past been able to echo each and every "match" to any string in the list and it works fine even for multiple matches. Thanks in advance. $openedfile = fopen( $db_file, 'r' ); if(!$openedfile) { echo"<br /><br />FILE COULD NOT BE OPENED! Please contact the Database administrator"; exit; } else {//1 while (!feof( $openedfile ) ) {//2 $line = trim(fgets( $openedfile )); if ( !empty( $line ) ) {//3 list($member,$psw) = explode( "|", $line ); //////////////////////////////////////////////////////////////////////////////////////// //Now check to see if the username is in the database // if($username == $member) { $logged = array($member, $psw); } if($logged[0] == $username) { echo"We have a match!"; exit; } else { echo"Sorry- no match"; exit; } }//2 }//3 fclose( $openedfile ); }//1 ?> Quote Link to comment Share on other sites More sharing options...
CyG64 Posted June 23, 2009 Share Posted June 23, 2009 Hi, you exit in either cases after you have read the first line... http://HoloGuides.com/php Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.