Any help would be greatly appreciated.
Goals:
1: Send a username / password based on a username and not someone remembering their
email address.
2: If it's possible to send an encrypted key, which would be a link to pass_update.php which would make the user change their password.
This is the form I use:
<table border="0" cellpadding="3" cellspacing="1" >
<tr>
<td valign="top"><strong>Enter your Username : </strong></td>
<td valign="top"><form name="form1" method="post" action="lost.php">
<input name="email_to" type="text" id="mail_to" size="25">
<input type="submit" name="Submit" value="Submit">
</form>
</td>
</tr>
</table>
Php to send information:
<?php
$host="localhost"; // Host name
$username='username'; // Mysql username
$password='password'; // Mysql password
$db_name='database name'; // Database name
//Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect to server");
mysql_select_db("$db_name")or die("cannot select DB");
// value sent from form
$email_to=$_POST['email_to'];
// table name
$tbl_name=table_name;
// retrieve password from table where e-mail = $email_to(name@url.com)
$sql="SELECT field,field FROM $tbl_name WHERE field='$email_to'";
$result=mysql_query($sql);
// if found this e-mail address, row must be 1 row
// keep value in variable name "$count"
$count=mysql_num_rows($result);
// compare if $count =1 row
if($count==1)
{
$rows=mysql_fetch_array($result);
// keep password in $your_password
$your_username=$rows['uname'];
$your_password=$rows['pw'];
// ---------------- SEND MAIL FORM ----------------
// send e-mail to ...
$to=$email_to;
// Your subject
$subject="Your login Information";
// From
$header="from: email@url.com <email@url.com>";
// Your message
$messages= "Your password for login to our website \r\n";
$messages.="Your username is $your_username \r\n";
$messages.="Your password is $your_password \r\n";
// send email
$sentmail = mail($to,$subject,$messages,$header);
}
// else if $count not equal 1
else
{
echo "Not found your email in our database";
}
// if your email succesfully sent
if($sentmail)
{
echo "Your Password Has Been Sent To Your Email Address.";
}
else
{
echo "Cannot send password to your e-mail address";
}
?>