Page 1 of 1

PHP sending forgotten password

Posted: Thu Feb 05, 2009 6:39 am
by gjessing
Hello
I need to modify this code for users who have forgotten their password.
the problem is if one user have more profiles with same email - then this script can’t send the user name and pass.

Example
user name : brian
email: myid@test.com

user name: hans
email: myid@test.com

maybe a loop .?
<?


$Query = mysql_query("select * from profiler where email = '$_POST[mail]'");
$Number = mysql_num_rows($Query);


if($Number == 1) {

$row = mysql_fetch_array($Query);
mail("$_POST[mail]","Genudsendelse af kodeord","Hej,

Your username is: $row[brugernavn]
Your password is...: $row[kodeord]

You are now ready to log on to http://www.xxx.dk

All the best
xxx.dk");


} else {
echo '<p><strong>We could not find your profile with this e-mail adresse ('.$_POST[mail].') </p>';
}
?>

Re: PHP sending forgotten password

Posted: Thu Feb 05, 2009 8:45 am
by susrisha
Find a method to uniquely search for the user's profile in the profiler table.
My guess is you must have kept a unique field in profiler. That is how you are supposed to get the query

Code: Select all

mysql_query("select * from profiler where unique_field ='$unique_field_posted'");
Well in your case, I would prefer you choose the username also as a parameter

Code: Select all

mysql_query("select * from profiler where email = '$_POST[mail]' AND user='$_POST['username']");
Probably that will return only one row by which you will be able to get the exact password.