Howdy There! I'm a pathetic newbie, trying to figure out how to recover a member's lost password from an external flatfile DB and send to the member's email address. The password is not encrypted. (Below are sample lines.)
Basically, the member will submit his/her email address to a form. If it matches an email found in field[0] it will send the password from field[1] to the email address.
Here's what I've got thus far, but dang... it doesn't work. Any kind assistance would be greatly appreciated!
Sample DB lines
Jack@nimble.com|YCFW039|Jack B Nimble|08/23/10 15:51:16
MonkeyPuss@abc.com|QLFE039|Abc Company|08/23/10 16:17:41
<?php
$email = $_POST["email"];
if (!isset($_POST['submit'])) { // if page is not submitted to itself echo the form
?>
<html>
<head>
<title>Password Finder</title>
</head>
<body>
<form method="post" action="<?php echo $PHP_SELF;?>">
<table style="width: 215px; margin-bottom: 0px; background-color: #F3F3F3;" cellpadding="6" cellspacing="0" align="center">
<tr>
<td colspan="2" style="text-align: center; height: 24px; font-family: Arial; font-size: 12px;">
<strong>Password Finder</strong></td>
</tr>
<tr>
<td style="font-family: Arial; font-size: 12px; width: 33px;">Email:</td>
<td><input type="text" style="width: 165px" maxlength="36" name="email"></td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="Send" name="submit"></td>
</tr>
</table>
</form>
<?php
} else {
$key = $email;
//load file into $fc array
$fc = file("db.txt");
//loop through array using foreach
foreach($fc as $line)
{
if (strstr($line,$key)) //look for $key in each line
$fields = explode('|', $line);
}
//email[0]|password[1]|membname[2]|stamp[3]
//$record = "$fields[0]|$fields[1]|$fields[2]|$fields[3]";
$sbmail = "noreply@whatever.com";
$sname = "whatever.com";
$to = "$fields[0]";
$membname = "$fields[2]";
$pswd = "$fields[1]";
$subject = "Password Finder";
$message = "Here is your Requested Ad Password \n\nName: $rname \n\nMember Name: $membname \nPassword: $pswd \n\nContact us if you need further assistance. \nhttp://www.whatever.com/ \n";
$from = "$sbmail";
$headers = "From: '$sname' <$from>";
if (mail($to,$subject,$message,$headers)) {
echo '<br><p style="font-family: Arial; font-size: 14px;text-align:center;color:red;"><b>Password has been Sent<br>to Registered Email Address!</b></p><br>';
} else {
echo '<br><p style="font-family: Arial; font-size: 14px;text-align:center;color:red;"><b>Confirmation failed...</b></p><br>';
}
}
?>