First of all:
if(!mysql_select_db($db_name,$link)){
echo "Could not connect to the database";
exit();
}
$email_row=mysql_query($email_query,$link);
if(!$email_row){
echo "Could not query the database!<br>\n";
echo "MySQL error: ".mysql_error();
exit();
}
The use of mysql_db_query is deprecated according to the PHP manual.
Second, I don't know what your $email_query looks like so I have to assume that it checks for the email address provided by the user via some sort of form. Also, I have to asume that $txt_original_email holds that email user provided.
So, try something like this:
if(mysql_num_rows($email_row)==0){
echo "Sorry, the email you provided doesn't exist in our database...";
exit();
}
$row=mysql_fetch_assoc($email_row);
//in $row['password'] is password from your database if there is one (assuming that the password is the name of the field)
if($row['password']==$txt_original_email){
mail($txt_original_email, "Your Password", "$mail_body $row[password]","From: you <you@somewhere.com>")
}
else{
echo "The email you provided isn't the same one we have in the database.";
exit();
}
I would appreciate to clear these my asumptions if any of this doesn't qwork i.e. I would like to take a look at the $email_query