I have a function that should notify a user of a new password.
the function is...
<?php
function notify_password($userName, $passwd)
// notify the user that their password has been changed
{
if (!($conn = db_connect()))
return false;
$result = mysql_query("select email from client_details
where userName='$userName'");
if (!$result)
{
return false; // not changed
}
else if (mysql_num_rows($result)==0)
{
return false; // userName not in db
}
else
{
$email = mysql_result($result, 0, 'email');
$from = "From: [email]admin@sorensen.co.uk[/email] \r\n";
$mesg = "Your Sorensen password has been changed to $password \r\n"
."Please change it next time you log in. \r\n";
if (mail($email, 'Sorensen login information', $mesg, $from))
return true;
else
return false;
}
}
?>
and it's called from this...
<?php
require_once("user_fns.php");
echo '<h3 align="center">Resetting password</h3>';
//creating short variable name
$userName = $_POST['userName'];
if ($passwd=reset_password($userName))
{
if (notify_password($userName, $passwd))
echo 'Your new password has been sent to your email address.';
else
echo 'Your password could not be mailed to you.'
.' Try pressing refresh.';
}
else
echo 'Your password could not be reset - please try again later.';
do_html_url('index.php', 'Login');
?>
When I enter a username from the sample db I get the message
'Your password could not be mailed to you.'
.' Try pressing refresh.'
I've replaced all the "return false" statements with "error 1, error 2, etc" to try and locate where it's going wrong, but i still get that same message.
Could it possibly be something in the php ini file... or my apache config ?????
I'm just using my home pc at the mo as a testing server (set to localhost) and the email addy in notify_passward() is fictitious (although replacing it with mine makes no difference!)
Any thoughts, suggestions and ideas would be very welcome! :¬)
THanks in advance
luds