I have a need to send an e-mail to someone who has lost their password. The way we set this up, a person might have several passwords depending on their access level. (This is a little screwy I know but there are a couple of reasons why we set it up like this) I want to send just one email that includes all passwords.
I'm using the following code but what's happening is depending on how many passwords someone has, that number plus one e-mail is getting sent out. So if there are three passwords in the dbase the user gets one email that includes the first password, then another email that includes the first and second password, then one that includes all three passwords, then one more that includes the first password -- like the first email sent out. How can I just get one email sent with all passwords?
Here's the code I use after querying the dbase and getting all records from login table that match the inputted email address and reminder clue:
while ($row = mysql_fetch_array($result)) {
$email = $row['email'];
$password = $row['password'];
$access_level = $row['access_level'];
$userinfo = array($access_level => $password);
foreach ($userinfo as $key => $value){
$info .= "Access Level: $key\nPassword: $value\n\n";
}
mail ("$email","Password found","$info","FROM:$admin_email");
}