PDA

View Full Version : How do I Send form Results to 2 e-mails


shineboy
11-25-2005, 08:51 PM
I'm building a purchase form using PHP implementing the suggestions from this site.
http://www.christian-web-masters.com/artic...ail-form-2.html ('http://www.christian-web-masters.com/articles/web_php-mail-form-2.html')
I'm pretty new with PHP but I was able to get this form to work.
It sent me the e-mail. But what I need is a reciept e-mail also sent back to the clients e-mail.
How would I set it up so that the client could specify his e-mail and then recieve a copy of
the trasaction?

Also if someone could suggest a PHP code that would allow for me to have the client's info passed along to an e-mail that would be great. The current one I'm using only lets them type a message and a subject. I want to setup fields for a registration form.

Thank you.

davidj
11-28-2005, 11:04 AM
this is a very easy script to follow and i have also COMMENT Overdosed just to help coz im that kinda guy B)

you can set your form to call this as a seperate page or add this to the top of your form page and set the form action to call itself (if you do the latter then you need some logic so it does not fire when the page first loads.)

You may need some email address validation but thats what i call an unessessary-nice-to-have


<?php
// $_POST['emailfield'] is the field that you catch the users email -
// from and then send through post method.
$add_address = $_POST['emailfield'];

/* recipients */
// this bit will add three addresses to send (remove the lines if not needed or remove the values
$to = "shineboy <shineboy@example.com>" . ", "; // note the comma
$to .= "<mymail@example.com>"; // you can add multi (TO) recipients here
$to .= $add_address; // this is the contents of the variable above

/* subject */
$subject = "this is an email example"; // you can send HTML in the message

// HTML example ****************************
/*$subject = '<table width="200" border="0">
<tr>
<td>content</td>
<td>content</td>
</tr>
<tr>
<td>image</td>
<td>link</td>
</tr>
</table>';*/
//******************************************

/* message */
$message = ' '; // you can set any default message or variable here

/* To send HTML mail, you can set the Content-type header. */
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

/* additional headers */
$headers .= "From: user <mymail@example.com>\r\n"; //you can name the site or your address here

$headers .= "Cc: mymail@example.com\r\n"; // Cc field. You could use the $add_address variable
$headers .= "Bcc: mymail2@example.com\r\n"; // Bcc field. You could use the $add_address variable

/* and now mail it */
mail($to, $subject, $message, $headers);

?>

shineboy
11-28-2005, 06:55 PM
Thank you,
I did try this method and was able to get an e-mail sent but there was no info from the form present. The only things that worked were the name of the person e-mailing and the subject of the e-mail, all the other fields that I filled out never showed up in the e-mail. What could I be doing wrong?

davidj
11-29-2005, 07:44 AM
paste the code that you used into this thread