This topic is locked
[SOLVED]

 Remind password page when many users have same email

5/18/2010 11:45:24 AM
PHPRunner General questions
F
FunkDaddy author

I am trying to do something similar to this post http://www.asprunner.com/forums/topic/13538-remind-password-when-multiple-users-have-same-email-address/pagep46841hlremindfromsearch1&#entry46841
What can I change in the remind.php page so that it reads and sends all records in my users table associated with the reminder email? For example, I have users who have multiple user accounts but use the same email address for all of them. Thus, when they enter their email as the option for remind password page, I would like it to send the reminder listing all of the user account Usernames and Passwords associated with the email they entered in the remind.php form.
I looked at the remind.php page and identified the SELECT query, but I don't know how to tell it to retrieve the other records... and send them in an email. I don't care if they send them all in the same email or if the system sends out multiple emails (one for each Username and Password)... whichever solution is easier works for me.
Thanks in advance for your help!!!
M

A
ashipley 5/18/2010

This may not come across as very "eloquent", but it works. I have had similar situations on my site as well.
The first thing I do is to set up a string to receive information. Then I open up the table with the e-mail addresses in it. I use a loop to go through all records from first to last, and on each record I look for a matching e-mail address. If there is a match, I read the field I want to retrieve data from, append it to my string, followed by whatever seprarator I want to us. I then repeat the loop until I reachthe last record. The string that you set up now contains the data from the desired field for every record in the table that matched your search criteria. You could set the string so that each time it found a match it would append a texxt string such as "User Name =", followed by the username string, followed by "Password = ", followed by the password. When you exit from the routine, have the event tab send the string to your user in an e-mail.
Arthur

F
FunkDaddy author 5/18/2010

Thanks Arthur!
Is there any way you could send me a sample of the loop? I am not well versed enought to write my own. I am assuming that you made these changes in the remind.php page as well, right?
Thanks in advance for your help again!
Best,
M

F
FunkDaddy author 5/19/2010

I received this response from Sergey



to send emails with detail about all account open remind.php file, find this code:

----------------------------------------

$strSQL="select ".AddFieldWrappers($cUserNameField).",".AddFieldWrappers($cPasswordField).",".AddFieldWrappers($cEmailField)." from `users` where ".$sWhere; $rs=db_query($strSQL,$conn);

if($data=db_fetch_numarray($rs))

----------------------------------------

and replace it with this one:

----------------------------------------

$strSQL="select ".AddFieldWrappers($cUserNameField).",".AddFieldWrappers($cPasswordField).",".AddFieldWrappers($cEmailField)." from `users` where ".$sWhere; $rs=db_query($strSQL,$conn);

while($data=db_fetch_numarray($rs))

----------------------------------------


However, it still only sends out the first email found in the users table, even though I need it to send out an email to all records that match the email entered in the forgot password page (and I don't care whether it send out one separate email for each record found or whether it groups all of the information into a single email - either way works for me).
If anyone out there has any insight based on this piece of code provided by Sergey please help.
I will post back once I hear back from support.
M

F
FunkDaddy author 5/20/2010

Finally got this working. For those of you looking to use this here is the answer I received from Jane (you rock!):



Find this code

----------------------------------------

if($tosearch)

{

$strSQL="select ".AddFieldWrappers($cUserNameField).",".AddFieldWrappers($cPasswordField).",".AddFieldWrappers($cEmailField)." from `users_tbl` where ".$sWhere;

$rs=db_query($strSQL,$conn);

if($data=db_fetch_numarray($rs))

{

$password=$data[1];

$url = GetSiteUrl();

$url.=$_SERVER["SCRIPT_NAME"];

$message="Password reminder"."\r\n";

$message.="You asked to remind your username and password at"." ".$url."\r\n";

$message.="Username".": ".$data[0]."\r\n";

$message.="Password".": ".$password."\r\n";

runner_mail(array('to' => $data[2], 'subject' => "Password reminder", 'body' => $message));

$reminded=true;

if(function_exists("AfterRemindPassword"))

AfterRemindPassword($strUsername,$strEmail);

$loginlink_attrs="href=\"login.php";

if($strSearchBy!="email")

$loginlink_attrs.="?username=".rawurlencode($strUsername);

$loginlink_attrs.="\"";

$xt->assign("loginlink_attrs",$loginlink_attrs);

$xt->assign("body",true);

$_SESSION[$strTableName."_count_captcha"]=$_SESSION[$strTableName."_count_captcha"]+1;

$xt->display("remind_success.htm");

return;

}

}

----------------------------------------

and replace it with this one

-------------------------------------

if($tosearch)

{

$strSQL="select ".AddFieldWrappers($cUserNameField).",".AddFieldWrappers($cPasswordField).",".AddFieldWrappers($cEmailField)." from `users_tbl` where ".$sWhere;

$rs=db_query($strSQL,$conn);

while($data=db_fetch_numarray($rs))

{

$password=$data[1];

$url = GetSiteUrl();

$url.=$_SERVER["SCRIPT_NAME"];

$message="Password reminder"."\r\n";

$message.="You asked to remind your username and password at"." ".$url."\r\n";

$message.="Username".": ".$data[0]."\r\n";

$message.="Password".": ".$password."\r\n";

runner_mail(array('to' => $data[2], 'subject' => "Password reminder", 'body' => $message));

}

if($data=db_fetch_numarray($rs))

{

$reminded=true;

if(function_exists("AfterRemindPassword"))

AfterRemindPassword($strUsername,$strEmail);

$loginlink_attrs="href=\"login.php";

if($strSearchBy!="email")

$loginlink_attrs.="?username=".rawurlencode($strUsername);

$loginlink_attrs.="\"";

$xt->assign("loginlink_attrs",$loginlink_attrs);

$xt->assign("body",true);

$_SESSION[$strTableName."_count_captcha"]=$_SESSION[$strTableName."_count_captcha"]+1;

$xt->display("remind_success.htm");

return;

}

}

-------------------------------------
F
FunkDaddy author 6/9/2010

I wanted to update this post because I ran into a bug after using the code I previously posted.
The bug caused the remind.php page to display "This email doesn't exist in our database" even though a user WAS a active and valid user. It would still perform the action of sending multiple emails (when user had more than one use account with same email), but left the user with the impression that something was wring because they got that error message. Plus, it failed to change the page to "proceed to login" which typically shows upon a successful reminder request.
Anyhow, bottom line is that you must find this line:

----------------------------------------------

if($data=db_fetch_numarray($rs))

----------------------------------------------
and add following code just before it:

----------------------------------------------

$rs=db_query($strSQL,$conn);

----------------------------------------------
Now it will work flawlessly!
Hope this helps someone,
Best,
Marcelo Ramagem

Z
zlatan24 7/22/2010

I quite frequently work with outlook password. But once something happened with it. I couldn't receive new emails from my friends. I didn't know what to do next. But luckily for me the software resolved my issue within seconds and utterly free of charge as I kept firmly in mind - ms outlook password recovery software. Above I knew about some possibilities of this application.