如何将FORM中的电子邮件添加到CC.php脚本中


How to add email from FORM into CC php script

我在html中有以下表单:

<form action="email.php" class="form">
    <fieldset>
    <legend>Formular contact</legend>
    <p class="nume">
        <input type="text" name="nume" id="nume" />
        <label for="nume">Nume</label>
    </p>
        <p class="prenume">
        <input type="text" name="prenume" id="prenume" />
        <label for="nume">Prenume</label>
    </p>
    <p class="companie">
        <input type="text" name="companie" id="companie" />
        <label for="companie">Companie</label>
    </p>
    <p class="email">
        <input type="text" name="email" id="email" />
        <label for="email">E-mail</label>
    </p>
    <p class="telefon">
        <input type="text" name="telefon" id="telefon" />
        <label for="telefon">Telefon</label>
    </p>
    <p class="text">
        <textarea name="text"></textarea>
        <label for="text">Mesaj</label>
    </p>

    <p class="submit">
        <input type="submit" value="Trimite">
        <input type="reset" value="Sterge" onClick="form()" />
    </p>
    </fieldset>
</form>

和以下php脚本:

<?php
$field_name = $_POST['nume'];
$field_firstname = $_POST['prenume'];
$field_companie = $_POST['companie'];
$field_email = $_POST['email'];
$field_message = $_POST['comentariu'];
$mail_to = 'example@gmail.com',;
$subject = 'New message from your website';
$headers = "From: comentariu@domain.com'r'n" .
**$hearders .= "Cc: .$_GET['email']'r'n";**
$headers .= "MIME-Version: 1.0'r'n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1'r'n";

$body = '<html><body>';
$body .= '<img src="http://www.bgd-group.ro/images/email.jpg" alt="BGD-GROUP" />';
$body .= '<p><center><strong><font color="red">Tabelul de mai jos contine datele completate de client pe site</font></strong></center></p>';
$body .= '<table rules="all" style="border-color: #666;" border="3" cellpadding="14">';
$body .= "<tr style='background: #eee;'><td><strong>Label</strong> </td><td><strong>Informatii client de pe site</strong></td></tr>";
$body .= "<tr><td><strong>Nume:</strong> </td><td>" . strip_tags($_GET['nume']) . "</td></tr>";
$body .= "<tr><td><strong>Prenume:</strong> </td><td>" . strip_tags($_GET['prenume']) . "</td></tr>";
$body .= "<tr><td><strong>Companie:</strong> </td><td>" . strip_tags($_GET['companie']) . "</td></tr>";
$body .= "<tr><td><strong>Email:</strong> </td><td>" . strip_tags($_GET['email']) . "</td></tr>";
$body .= "<tr><td><strong>Telefon:</strong> </td><td>" . strip_tags($_GET['telefon']) . "</td></tr>";
$body .= "<tr><td><strong>Mesaj:</strong> </td><td>" . strip_tags($_GET['comentariu']) . "</td></tr>";
$body .= "</table>";
$body .= "</body></html>";
//pana aici
$mail_status = mail($mail_to, $subject, $body, $headers);
if ($mail_status) { ?>
    <script language="javascript" type="text/javascript">
        alert('Multumim pentru mesaj! Va vom contacta noi in cel mai scurt timp posibil');
        window.location = 'index.html';
    </script>
<?php
}
else { ?>
    <script language="javascript" type="text/javascript">
        alert('Mesajul nu a fost trimis! Va rugam reincercati.');
        window.location = 'contact2.html';
    </script>
<?php
}
?>

粗线是我想要添加的内容$hearder.="抄送:来自表单的电子邮件''r''n"我想在抄送中添加表格中填写的电子邮件。这怎么可能呢。请帮帮我。

而不是

$hearders .= "Cc: .$_GET['email']'r'n";

试试(也要注意"headers"的拼写):

$headers .= "Cc: ".$_GET['email']."'r'n";

如果你纠正了你的拼写错误,这是可行的;)

**$hearders .= "Cc: .$_GET['email']'r'n";**
$headers .= "Cc: .$_GET['email']'r'n";