By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,592 Members | 1,958 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,592 IT Pros & Developers. It's quick & easy.

forgot password email works but registeration doesnt

P: 29
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

Expand|Select|Wrap|Line Numbers
  1.  header("Location: ".$session->referrer);
  2.  
  3.       {
  4.          /* Generate new password */
  5.          $newpass = $session->generateRandStr(8);
  6.  
  7.          /* Get email of user */
  8.          $usrinf = $database->getUserInfo($subuser);
  9.          $email  = $usrinf['email'];
  10.  
  11.          /* Attempt to send the email with new password */
  12.          if($mailer->sendNewPass($subuser,$email,$newpass)){
  13.             /* Email sent, update database */
  14.             $database->updateUserField($subuser, "password", md5($newpass));
  15.             $_SESSION['forgotpass'] = true;
  16.          }

Expand|Select|Wrap|Line Numbers
  1.  function sendNewPass($user, $email, $pass){
  2.       $from = "From: ".EMAIL_FROM_NAME." <".EMAIL_FROM_ADDR.">";
  3.       $subject = "Elite ticket master - Your new password";
  4.       $body = $user.",\n\n"
  5.              ."We've generated a new password for you at your "
  6.              ."request, you can use this new password with your "
  7.              ."username to log in to Eliteticketsevents Site.\n\n"
  8.              ."Username: ".$user."\n"
  9.              ."New Password: ".$pass."\n\n"
  10.              ."It is recommended that you change your password "
  11.              ."to something that is easier to remember, which "
  12.              ."can be done by going to the My Account page "
  13.              ."after signing in.\n\n"
  14.              ."- EliteTickets's Site";
  15.  
  16.  
  17.               $server = "smtp.virgin.net";
  18.  ini_set("SMTP",$server);
  19.  
  20.  
  21.  
  22.       return mail($email,$subject,$body,$from);
but now i tried to do the same to register but doesnt send the email

Expand|Select|Wrap|Line Numbers
  1.  if($retval == 0){
  2.          $_SESSION['reguname'] = $_POST['user'];
  3.          $_SESSION['regsuccess'] = true;
  4.          header("Location: ".$session->referrer);
  5.  
  6.          if($mailer->sendWelcome($user, $email, $pass)){
  7.  
  8.          }

Expand|Select|Wrap|Line Numbers
  1.   function sendWelcome($user, $email, $pass){
  2.       $from = "From: ".EMAIL_FROM_NAME." <".EMAIL_FROM_ADDR.">";
  3.       $subject = "Elite ticket master - Welcome!";
  4.       $body = $user.",\n\n"
  5.              ."Welcome! You've just registered at EliteTickets Site "
  6.              ."with the following information:\n\n"
  7.              ."Username: ".$user."\n"
  8.              ."Password: ".$pass."\n\n"
  9.              ."If you ever lose or forget your password, a new "
  10.              ."password will be generated for you and sent to this "
  11.              ."email address, if you would like to change your "
  12.              ."email address you can do so by going to the "
  13.              ."My Account page after signing in.\n\n"
  14.              ."- EliteTickets's Site";
  15.  
  16.  
  17.  
  18.  
  19.       return mail($email,$subject,$body,$from);
  20.    }
Apr 22 '10 #1
Share this Question
Share on Google+
1 Reply


P: 3
not exactly same! why register doesn't have this $server = "smtp.virgin.net";
ini_set("SMTP",$server);
Apr 23 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.