Jump to content

PHP form: email separate confirmation emails to User and me...


Recommended Posts

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);

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.

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);


This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.