Jim R Posted September 10, 2012 Share Posted September 10, 2012 I have an HTML form set up, processed by PHP to enter information into a database and send me a confirmation email. It's worked great for two years, but I'm getting to the numbers where I'd like to have a separate confirmation email sent to the User after they register. Most of what I search for online, here and at PHP Manual sets up sending the same message to multiple people. Here is what I have being sent to me: // Email to me $message = $_POST['nameFirst'] . " " . $_POST['nameLast'] ." has entered the fall league.\n"; $message .= $_POST['feet'] . "'" . $_POST['inches'] ."\", " . $_POST['grade'] . "; " . $_POST['school'] ."\n"; $message .= $_POST['nameParent']."\n"; $message .= $_POST['email']; // In case any of our lines are larger than 70 characters, we should use wordwrap() $message = wordwrap($message, 70); $headers = "From: " . $_POST['nameFirst'] . " " . $_POST['nameLast'] . " <" . $_POST['email'] . ">"; // Send mail('basketball@metroindybasketball.com', '2012 Fall League Registration', $message, $headers); Below is what I'm trying to send to my Users. I thought changing the variables would create the separate emails, but all I'm getting is the above email twice. // Confirmation email to the player $confirm = "This is to confirm that" . $_POST['nameFirst'] . " " . $_POST['nameLast'] ." has entered the Metro Indy Basketball Fall League.\n\n"; $confirm .= "Thank you for entering. Information on which team your son will be on and any updates will be posted at http://metroindybasketball.com around Wednesday, the week leading up to the start of the league. It starts Sunday, September 30. You may also follow us on Twitter: MetroIndyBBall and search for #MIBFL.\n\n"; $confirm .= "We are looking forward to the start of our sixth season!\n\n"; $confirm .= "Take care,\n\n"; $confirm .= "My Name Goes Here"; // In case any of our lines are larger than 70 characters, we should use wordwrap() $confirm = wordwrap($message, 70); $confirmHeaders = "From: Metro Indy Basketball <basketball@metroindybasketball.com>"; // Send mail($_POST['email'], '2012 Fall League Registration', $confirm, $confirmHeaders); Quote Link to comment https://forums.phpfreaks.com/topic/268241-php-form-email-separate-confirmation-emails-to-user-and-me/ Share on other sites More sharing options...
Jessica Posted September 10, 2012 Share Posted September 10, 2012 What's in $_POST['email']? Quote Link to comment https://forums.phpfreaks.com/topic/268241-php-form-email-separate-confirmation-emails-to-user-and-me/#findComment-1376872 Share on other sites More sharing options...
Jim R Posted September 10, 2012 Author Share Posted September 10, 2012 The User's email address they use in the form. Quote Link to comment https://forums.phpfreaks.com/topic/268241-php-form-email-separate-confirmation-emails-to-user-and-me/#findComment-1376873 Share on other sites More sharing options...
Jessica Posted September 11, 2012 Share Posted September 11, 2012 $confirm = wordwrap($message, 70); Quote Link to comment https://forums.phpfreaks.com/topic/268241-php-form-email-separate-confirmation-emails-to-user-and-me/#findComment-1376882 Share on other sites More sharing options...
Jim R Posted September 11, 2012 Author Share Posted September 11, 2012 That wraps the email message after 70 characters in the event of a longer message. The $confirm is what I altered from $message for the second email. Quote Link to comment https://forums.phpfreaks.com/topic/268241-php-form-email-separate-confirmation-emails-to-user-and-me/#findComment-1376895 Share on other sites More sharing options...
Jim R Posted September 11, 2012 Author Share Posted September 11, 2012 Figured it out. The issue I had was the line you copied last. The $message,70 needed to be $confirm,70. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/268241-php-form-email-separate-confirmation-emails-to-user-and-me/#findComment-1376904 Share on other sites More sharing options...
Jessica Posted September 11, 2012 Share Posted September 11, 2012 Is this your actual code? Your second block uses $confirm then you replace it with $message. I'm not asking what your code does because I don't understand, I'm asking because I think *you* don't understand. That's why you get the same email rather than two different emails. If this is your actual code, I don't see why it would go to your email instead of the user, unless you entered your email in the form. Quote Link to comment https://forums.phpfreaks.com/topic/268241-php-form-email-separate-confirmation-emails-to-user-and-me/#findComment-1376907 Share on other sites More sharing options...
Jim R Posted September 11, 2012 Author Share Posted September 11, 2012 Like I said, when I changed $confirm = wordwrap($message, 70); to $confirm = wordwrap($confirm, 70); It worked. I changed the language of the email's body, but here is the code for the second email being sent: // Confirmation email to the player $confirm = 'Hello, This is to confirm that ' . $_POST['nameFirst'] . ' ' . $_POST['nameLast'] .' has entered the Metro Indy Basketball Fall League. Thank you for entering. If you have not paid yet, you can do so at http://metroindybasketball.com/payment. Information on which team your son will be on and any updates will be posted at http://metroindybasketball.com, or you can also follow us at Twitter: @MetroIndyBBall or follow the search term #MIBFL. If you would like to see a list of those who are committed to play, you can check that out at http://metroindybasketball.com/committed. The #MIBFL starts Sunday, September 30, and runs through Sunday, October 28. We will post rosters the week leading up to the first day, likely on that Wednesday. Once the league starts, the website is also where you will find results. We are looking forward to the start of our sixth season! Thank you again for registering, Name Here'; // In case any of our lines are larger than 70 characters, we should use wordwrap() $confirm = wordwrap($confirm, 70); $confirmHeaders = "From: Metro Indy Basketball <basketball@metroindybasketball.com>"; // Send mail($_POST['email'], '2012 Fall League Registration', $confirm, $confirmHeaders); Quote Link to comment https://forums.phpfreaks.com/topic/268241-php-form-email-separate-confirmation-emails-to-user-and-me/#findComment-1376925 Share on other sites More sharing options...
Jessica Posted September 11, 2012 Share Posted September 11, 2012 I didn't see your second message when I posted, I was using the mobile site so that might be why. Glad you got it figured out. Quote Link to comment https://forums.phpfreaks.com/topic/268241-php-form-email-separate-confirmation-emails-to-user-and-me/#findComment-1377009 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.