Hi,
I'm very new to PHP.
I've been working on this code for password recovery for a week and I'm pretty close, but I'm having problems understanding why I keep getting the:
"Can not send password to your email address". I know for certain that it has found the email in the table, but why is it still having problems sending? There are no other error messages thrown.
function frm_lostpass()
{
global $skn,$In,$db,$Film,$Url,$Date,$module,$userinfo;
if(isset($_GET['check']) and trim($_GET['check'])=='ok')
{
$email = $In->get('email',0,'');
$sql_check ="SELECT Count(m.Email) AS numrows FROM tbl_member AS m\n"
."WHERE m.Email = '$email'\n";
$numrow=$db->sql_get_first($sql_check);
if($numrow['numrows']!=1)
{
return "<center>Email not found !</center>";
}
else
{
global $skn,$In,$db,$Film,$Url,$Date,$module,$userinfo;
// value sent from form
$email_to=$_POST['email_to'];
// retrieve password from table where e-mail = $email_to
$sql ="SELECT m.Password FROM tbl_member AS m\n"
."WHERE m.Email = '$email'\n";
$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_password=$rows['password'];
// ---------------- SEND MAIL FORM ----------------
// send e-mail to ...
$to=$email_to;
// Your subject
$subject="Your password here";
// From
$header="example@example.com";
// Your message
$messages= "Your password for login to our website \r\n";
$messages.="Your password is $your_password \r\n";
$messages.="more message... \r\n";
// send email
$sentmail = mail($to,$subject,$messages,$header);
}
// else if $count not equal 1
else {
return "That email address is not found in our database";
}
// if your email succesfully sent
if($sentmail){
return " Your Password Has Been Sent To Your Email Address.";
}
else {
return " Cannot send password to your e-mail address";
}
}
}
else
{
$skn ->set_file( 'lost_pass', 'member/frm_lostpass.html' );
return $skn -> output('lost_pass');
}
}