Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1090621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:24:08+00:00 2026-05-16T23:24:08+00:00

I have an html form the links to a PHP email. The form works

  • 0

I have an html form the links to a PHP email. The form works well, but I am having trouble with the Cc and Bcc not coming through.

Here is the entire code. Please review and help me understand what I am getting wrong on the Cc and Bcc parts in the headers.

Thanks:

<?php
    $emailFromName = $_POST['name'];
    $emailFrom = $_POST['email'];
    $emailFromPhone = $_POST['phone'];
    $email9_11 = $_POST['9-10'];
    $email10_11 = $_POST['10-11'];
    $email11_12 = $_POST['11-12'];
    $email12_1 = $_POST['12-1'];

    if (empty($emailFromName)) {
        echo 'Please enter your name.';
    } elseif (!preg_match('/^([A-Z0-9\.\-_]+)@([A-Z0-9\.\-_]+)?([\.]{1})([A-Z]{2,6})$/i', $emailFrom) || empty($emailFrom)) {
        echo 'The email address entered is invalid.';   
    } else {

        $emailTo = "main@gmail.com" ;
        $subject = "Family History Conference Registration";


       if (!empty($emailFrom)) {
    $headers = 'From: "' . $emailFromName . '" <' . $emailFrom . '>';
        } else {
            $headers = 'From: Family History Conference <noreply@domain.org>' . "\r\n";
            $headers .= 'Cc: $emailFrom' . "\r\n";
            $headers .= 'Bcc: myemail@domain.com' . "\r\n";
        }

        $body = "From: ".$emailFromName."\n";
        $body .= "Email: ".$emailFrom."\n";
        $body .= "Phone: ".$emailFromPhone."\n\n";
        $body .= "I would like to attend the following classes.\n";
        $body .= "9:10 to 10:00: ".$email9_11."\n";
        $body .= "10:10 to 11:00: ".$email10_11."\n";
        $body .= "11:10 to 12:00: ".$email11_12."\n";
        $body .= "12:10 to 1:00: ".$email12_1."\n";

        /* Send Email */
        if (mail($emailTo, $subject, $body, $headers)) {
            echo "<h2>Thank you for Registering</h2>
            <h3>You have registered for the following classes</h3>
            <p>9:10 to 10:00am: \"$email9_11\" <br />
             10:10 to 11:00am: \"$email10_11\"<br />
             11:10 to 12:00:  \"$email11_12\"<br />
             12:10 to 1:00: \"$email12_1\"</p>
        <p>We look forward to seeing you October 31, 2010</p>";


        } else {
            echo 'There was an internal error while sending your email.<br>';
            echo 'Please try again later.';    
        }
    }
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T23:24:08+00:00Added an answer on May 16, 2026 at 11:24 pm

    You’re using single quotes

    $headers .= 'Cc: $emailFrom' . "\r\n";
    

    PHP won’t interpret variables inside single quotes, you must use double quotes

    $headers .= "Cc: $emailFrom\r\n";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a html form <form action=process.php method=post> <input type=checkbox name=name[v1] /> <input type=checkbox
I have this html form <form enctype=multipart/form-data action=upload.php method=POST> <textarea rows=5 cols=50 name=links id=links
Say I have an HTML form like this to collect an email from a
Hey all, I have a basic HTML contact form that goes to a .php
I have a PHP email form and the user enters their email and it
I have an HTML, PHP - Jquery form. The last input is a file
I have a HTML form that contains many links (around 17). I want, when
i have html form i am using <a href="#" onclick="document.aa.submit()"> instead of submit button
I have a following problem, I have HTML form that uploads a file with
My input tag started to go crazy... I have html form for input to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.