Jump to content

list() and if statement problem


meltingpoint

Recommended Posts

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

 

?>

Link to comment
https://forums.phpfreaks.com/topic/163217-list-and-if-statement-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.