not the complete code, but the important bit....
$sql = "SELECT * FROM usertable WHERE usernamefield LIKE $user";
$result = sql_query($sql);
if (sql_num_rows($result) == 1)
{
$row = sql_fetch_assoc($result);
$pword = $row['passwordfield'];
$email = $row['emailfield'];
$mailsubject = "Your password";
$mailbody = "Your Password is $pword";
mail($email, $mailsubject, $mailbody);
}
hope this helps...