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

Emailing user information problem

P: 155
I want to email the results of a form to the user. Everything is being emailed except for $company, $address, $city, $state and $zip.

I'm obviously not working the ." correctly. How is the proper way of doing this? Thanks.

[PHP] function sendWelcome($user, $email, $pass){
$from = "From: ".EMAIL_FROM_NAME." <".EMAIL_FROM_ADDR.">";
$subject = "website - Welcome!";
$body = $user.",\n\n"
."Welcome! You've just registered! "
."with the following information:\n\n"
."Username: ".$user."\n"
."Password: ".$pass."\n\n"
."".$city.", ".$state." ".$zip."\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"
."- admin";

return mail($email,$subject,$body,$from);
Jul 25 '07 #1
Share this Question
Share on Google+
4 Replies

Expert 5K+
P: 5,821
Heya, David.

You'll probably find that it's easier to maintain just to do this:

Expand|Select|Wrap|Line Numbers
  1. $body = <<<EBODY
  2. {$user},
  4. Welcome! You've just registered with the following information:
  6. Username: {$user}
  7. Password: {$pass}
  9. {$company}
  10. {$address}
  11. {$city}, {$state} {$zip}
  13. 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.
  15. - admin
  16. EBODY;
I like to enclose my variables within curly braces when using heredoc syntax, but it is not strictly necessary.
Jul 25 '07 #2

P: 155
Thanks, it certainly looks easier.
Jul 26 '07 #3

Expert 100+
P: 1,044
One thing to note about that is that you don't have any control over special characters such as \r and \n.
Jul 26 '07 #4

Expert 5K+
P: 5,821
Are you getting blank values where the company name, address, etc. should go? Your function only takes the Username, email address and password as arguments. Is this intentional?
Jul 26 '07 #5

Post your reply

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