I have a PHP Login using a flat file (.txt) system with a username and password this is in a file called users.txt and they are in the following layout e.g.

User1||Password1

User2||Password2

User3||Password3

Till now I managed to get users to login based on their username and paswords.

Now I would like a PHP code so that when users login using the above method, a custom comment is displayed based on the username. I would like this in a separate text file, and to be displayed according to how the user logged in e.g.

User1||Hello John, you look great

User2||Don't let the rain spoil your day

User3||Hooray for holidays

So if User1 logs in using his username and password - only they can see their associated comment, and the same for the others.

How can this be done please?

I was thinking of having a code similar to this 

```
$name = $_SESSION["valid_user"]; 
$comments = $_POST['comments']; 
$file = file_get_contents("comments.txt"); 
if(strstr($file, "$name||$comments"))

```