PDA

View Full Version : How To Include a CC on a PHP Form


vinyl-junkie
24-08-2003, 23:48/11:48PM
This is related to another forum topic, but I have a PHP contact form that I'd like to include a CC back to the sender of the form. I have to confess I'm pretty ignorant when it comes to PHP. (I got the script off a website). I have this statement in the existing form:

mail("$SendToEmail", $yoursubject, $emailtext, "From: $email");

How would I modify it to include a CC, or would there just be a separate statement to mail back to the person who filled out the form?

nlopes
31-08-2003, 08:21/08:21AM
Thats very simple!

Just do this:


$headers="From: $email\n";
$headers.="CC: $cc_mail";

mail($SendToEmail, $subject, $emailtext, $headers);

Dan0
31-08-2003, 12:18/12:18PM
In other words, if it's not a feature of the canned script you've installed, you'd need to monkey with the source code to add that.

You could add the code provided by nlopes right above the mail() function as shown, then you just need a form field called "cc_mail" or if the CC: will always go to the same address, you can replace $cc_mail in nlopes' code with that address.

With PHP, form fields are automagically converted into variables that you can use.

vinyl-junkie
31-08-2003, 20:11/08:11PM
Thanks, nlopes and Dan0, for the replies. What I'm wanting to do with this is send an automated reply back to the person filling out the form on my website, so they'll have a record of the e-mail they sent me. I'll also include something to that effect in the thank you message that I have as part of this process right now.

I'm on vacation, and away from my own computer, so this will have to wait until I get back home to try it. I've gone from a "Ferrari" (a.k.a. cable internet) to a "Yugo" (56K modem) at my sister's house, so just being able to do much on the internet is a real challenge. ;)