I have the following script:
$('#login-box .forgot-pwd').click(function (e) {
e.preventDefault();
$('#login-box #main-login').hide("fast");
$('#login-box .login-error').hide();
$('#login-box #forgot-login').show("fast");
$('#forgot-username').focus();
$('#login-box .forgot-send').click(function (e) {
e.preventDefault();
$.ajax({
url: '/login.php',
data: $('#login-box form.get-password').serialize() + '&action=forgot',
type: 'POST',
success: function(html) {
if (html == 'success') {
$('#login-box #forgot-login').hide("fast");
$('#login-box').append('<p>Your password has been emailed to you</p>');
$('#mask , .login-popup').delay(1500).fadeOut(300 , function() {
$('#mask').remove();
});
} else {
$('#login-box .login-error').show("fast");
}
}
});
});
});
For forgotten password. The PHP is:
$email = trim($_POST['forgot-username']);
$objcustomer = new customer;
$objcustomer->get_pwd($email);
$cust_auth=$objcustomer->password;
if (!empty($cust_auth)) {
$to=$email;
$from='......';
$subject = '......';
$headers = "From: ......\r\n";
$headers.= "Reply-To: $from\r\n";
$headers.= 'Content-type: text/plain;charset="iso-8859-1"';
$message="Your ...... password is:\n\n" .
"$cust_auth\n\n" .
"Please return to ...... and login to continue your order.";
mail($to, $subject, $message, $headers);
echo 'success';
} else {
echo 'fail';
}
The problem is that on success, the email is sent but the modal box shows the error text, not the success text so I am presuming I am missing something in getting and reading whether the script was successful and I can't work out what.
Can anyone help please?