Hey all,
I found this script somewhere on these board, but can't get the whole thing to work.
It sends the UN & PW to the correct email that was input to the form from the first page, but I can't get any of these messages to show, such as if they don't exist in the DB. What am I doing wrong?
thanks for any help.
here's the code.
<?
if ($email) {
MYSQL_CONNECT('localhost','UN','PW');
@mysql_select_db("database");
$db = "database";
$query_checkemail = "SELECT * FROM members WHERE Email = '$email'";
$result_checkemail = mysql_query($query_checkemail);
if (!$result_checkemail) {
echo("Error performing query: " . mysql_error());
exit;
}
$recordcount_checkemail = mysql_num_rows($result_checkemail);
if ($recordcount_checkemail) {
while($row_checkemail = mysql_fetch_array($result_checkemail)) {
$username = $row_checkemail["UserName"];
$password = $row_checkemail["Password"];
$mail_to = trim($email);
$mail_headers = "From: mysite.com\r\nReply-to: [email]info@mysite.com[/email]";
$mail_subject = "Your login details for mysite.com:";
$mail_body .= "Username = $username\n";
$mail_body .= "Password = $password\n\n";
$mail_body .= "Don't forget that they are case sensitive!\n\n";
$mail_body .= "To sign up to mysite Wireless, go to:\n";
$mail_body .= "http://www.mysite.com/\n\n";
$mail_body .= "Yours,\n\n";
$mail_body .= "mysite.com Team\n\n";
mail($mail_to, $mail_subject, $mail_body, $mail_headers);
$message = "<center><p><font face=\"verdana\">Your password has been sent to $email</p></center>";
print "$message";
?>
<div align="center"><a href="javascript:window.close();"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Close</font></a><?
}
} else {
$message = "<center><p><font face=\"verdana\" color=\"#FF0000\"> <b>NOT FOUND</b></font> <br> <font face=\"verdana\">Your e-mail address, <b>$email</b>, is not in our database.
This means you are not a member of mysite.com. <br> <a href=\"forgotpw01.php\">Go Back</a></font></p></center>";
print "$message";
}
} else {
$message = "<center><p><font face=\"verdana\" color=\"#FF0000\"> <b>You didn't enter your e-mail address!</b></font><br><font face=\"verdana\"><a href=\"forgotpw01.php\">Go Back</a></font></p></center>";
print "$message";
}
?>
UPDATE 01: You can tell I'm still a real newbie!!
I forgot to put the damn "print" statements in!! DOH!! 😃 :p
UPDATE 02: I replaced the above code with the one that's now working for me.