Lisa23 Posted April 22, 2010 Share Posted April 22, 2010 i have a form if user forgot password it send the new password to the user email but now i'm trying to is to also send when user register but is not wrking this is the forgot password which works perfectlty header("Location: ".$session->referrer); { /* Generate new password */ $newpass = $session->generateRandStr(; /* Get email of user */ $usrinf = $database->getUserInfo($subuser); $email = $usrinf['email']; /* Attempt to send the email with new password */ if($mailer->sendNewPass($subuser,$email,$newpass)){ /* Email sent, update database */ $database->updateUserField($subuser, "password", md5($newpass)); $_SESSION['forgotpass'] = true; } function sendNewPass($user, $email, $pass){ $from = "From: ".EMAIL_FROM_NAME." <".EMAIL_FROM_ADDR.">"; $subject = "Elite ticket master - Your new password"; $body = $user.",\n\n" ."We've generated a new password for you at your " ."request, you can use this new password with your " ."username to log in to Eliteticketsevents Site.\n\n" ."Username: ".$user."\n" ."New Password: ".$pass."\n\n" ."It is recommended that you change your password " ."to something that is easier to remember, which " ."can be done by going to the My Account page " ."after signing in.\n\n" ."- EliteTickets's Site"; $server = "smtp.virgin.net"; ini_set("SMTP",$server); return mail($email,$subject,$body,$from); but now i tried to do the same to register but doesnt send the email if($retval == 0){ $_SESSION['reguname'] = $_POST['user']; $_SESSION['regsuccess'] = true; header("Location: ".$session->referrer); if($mailer->sendWelcome($user, $email, $pass)){ } function sendWelcome($user, $email, $pass){ $from = "From: ".EMAIL_FROM_NAME." <".EMAIL_FROM_ADDR.">"; $subject = "Elite ticket master - Welcome!"; $body = $user.",\n\n" ."Welcome! You've just registered at EliteTickets Site " ."with the following information:\n\n" ."Username: ".$user."\n" ."Password: ".$pass."\n\n" ."If you ever lose or forget your password, a new " ."password will be generated for you and sent to this " ."email address, if you would like to change your " ."email address you can do so by going to the " ."My Account page after signing in.\n\n" ."- EliteTickets's Site"; return mail($email,$subject,$body,$from); } Link to comment https://forums.phpfreaks.com/topic/199430-forgot-password-email-works-but-registeration-doesnt/ Share on other sites More sharing options...
AdRock Posted April 23, 2010 Share Posted April 23, 2010 Looks to me like you are being redirected before the mail is sent header("Location: ".$session->referrer); Link to comment https://forums.phpfreaks.com/topic/199430-forgot-password-email-works-but-registeration-doesnt/#findComment-1046760 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.