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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.