PHP sending forgotten password

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gjessing
Forum Newbie
Posts: 1
Joined: Thu Feb 05, 2009 6:38 am

PHP sending forgotten password

Post 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>';
}
?>
User avatar
susrisha
Forum Contributor
Posts: 439
Joined: Thu Aug 07, 2008 11:43 pm
Location: Hyderabad India

Re: PHP sending forgotten password

Post 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.
Post Reply