Jump to content

Password retrieval from MySQL Database


edsalin

Recommended Posts

Hello everyone!!  Need help with this little piece of code to retrive a password from a MySQL database and send it to the users email, it checks if the e-mail exists and outputs the correct statement, but if the e-mail does exist it goes straight to the "Sorry please try again later" and does not send the e-mail.....any ideas?

 

//retrieve password
	function retrieve($email){

	  $stmt = "select * from members where primary_email = '$email'";
	  $re = mysql_query($stmt, $this->link->link);
	  
	  if(mysql_num_rows($re)==0)
	     return "Sorry, this email address is not in our database";
	  else{
	     $row = mysql_fetch_assoc($re);

		 //do email
		 $to = $email;
		 $subject = "Your password for member area";
		 $message ="Hi ".$row['first_name'].",\n\nYour password to members area is following:\n\n".$row['password'].
		          
		 $header = "From: [email protected]/r/n";

		 if (mail($to, $subject, $message, $header))
			 return "Your password is on the way to your email address";
		 else
		     return "Sorry, please try again later.";
	  }
	     
	}

Link to comment
https://forums.phpfreaks.com/topic/172031-password-retrieval-from-mysql-database/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.