I get a user.txt file. There are all the users saved in this format:
Vorname: Michael | Nachname : Schmidt | Username: DarkDecipio | Passwort: 3609e297fb0b6fb1105cba71d5c024b3
Vorname: John | Nachname : Doe | Username: Dummy | Passwort: d78c03d72e72b44a131d255aec3c8a11
Now when a new User send a register form to the php file, i want to look, if the username is already taken.
So i must search all Username’s, if there the sended username. But i can’t do it with strstr() or something like that, because the Prename (Vorname) or Surname (Nachname) can be the same like the Username. Or the username can include a part of the sended username…
Hope you understand it.
Note: I know it’s a ugly solution to save users in a text file, but this is a project in my school and we MUST use textfiles…
Off the top of my head, I can think of two options. Assume $line is the current line in your file and you are looking for ‘DarkDecipio’:
First, use regular expressions to ensure you are picking up the section you want:
Second, split the lines by | and then use strstr on the third item in each array: