Forums

PHP

This topic is locked

Forgotton Username or Password Retrieval

Posted 17 Oct 2001 15:24:20
1
has voted
17 Oct 2001 15:24:20 Stephen Bateman posted:
Yet again I have hit a brain dead zone <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>

Can anyone help me create a simple form / memthod for searching a user database based on the entry in a "e-mail" FORM field. Then if a record is found matching the e-mail address extract the username and password and send it to the user's address.

I can find tutorials for ASP but none for PHP.

Thanks in advance.

GT

Replies

Replied 17 Oct 2001 16:31:45
17 Oct 2001 16:31:45 Michael O'Neill replied:
This a script I use to do just this. It is based on the username rather than the email but you should have no probs changing it. The script is not the tidiest, if you have any probs with it please let me know and I will try to help.
Mike.

&lt;?php

@ $db = mysql_pconnect("localhost", "username", "password";
mysql_select_db("dbname";
$query = "SELECT * from userinfo WHERE username = '$username'";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
if ($num_results &lt; 1)
{
$header = "No Such Username!"; //displays this if no username exists
}
else
{
$row = mysql_result($result, 0, "password"; //send password reminder
$row2 = mysql_result($result, 0, "email";
$toaddress = $row2;
$subject = "your subject";
$mailcontent = "Your password is ".$row;
$fromaddress = "from address";
$additional_headers = "From: from address";
mail($toaddress, $subject, $mailcontent,$additional_headers);
$header = "Your password has been sent to ".$row2;
}
?&gt;



Edited by - carphone on 10/17/2001 16:34:21

Reply to this topic