If I were you I wouldn't store data in txt. I would use database or XML file.
Example of xml structure:
<?xml version="1.0" encoding="UTF-8" ?>
<users>
<user>
<firstname>John</firstname>
<lastname>Doe</lastname>
<adress>aaa 23 street</adress>
<email>aaa@gmail.com</email>
<sex>male</sex>
<age>1987</age> <!-- better to use year of birth -->
<password>dkfzlkxcvzxkcv</age> <!-- password's hash -->
</user>
</users>
With such structure of file you can use simple xml
function findEmail()
{
if (file_exists('users.xml'))
{
$xml = simplexml_load_file('test.xml');
foreach ($xml->users->user as $user)
{
if($user->email == $_POST['email']) return true;
}
}
return false;
}
Read more about Simple XML -> http://www.php.net/manual/en/book.simplexml.php Using XML has a lot of advantages you should consider it in your project. However, if you don't want to use it. To read file to array where element of array is a line you should use function file()