繁体   English   中英

无法将清单从HTML发送到电子邮件

[英]Can't send checklist to email from html

我需要用两个部分来做一个简单的脚本。 第一个只是发送姓名,电话号码等,并且已经可以正常使用了:

但是在此之后,我需要将检查清单发送到同一封电子邮件,但仍然没有。

我的html:

 <form action="contact.php" method="post" id="form" class="contact-form"> <table style="color: DEB441; font-size: 19px; margin-left: 60px; margin-top: 40px; float: left;"> <tr> <td><font color="FFFFFF">Imie:</td> <td style="padding:0px"> <textarea style="outline-color: DEB441; margin-left: 23px; margin-bottom: 5px; overflow:auto;width:269px;height:15px;border:1px solid #DEB441;background:#fff;padding:3px 5px;color:#3D1E09;font:14px;font-style:italic;margin:0" name="cf_imie" rows="2" cols="20"></textarea> </td> </tr> <tr> <td><font color="FFFFFF">Nazwisko:</td> <td style="padding:0px"> <textarea style="outline-color: DEB441; margin-left: 23px; margin-bottom: 5px; overflow:auto;width:269px;height:15px;border:1px solid #DEB441;background:#fff;padding:3px 5px;color:#3D1E09;font:14px;font-style:italic;margin:0" name="cf_nazwisko" rows="2" cols="20"></textarea> </td> </tr> <tr> <td><font color="FFFFFF">Adres:</td> <td style="padding:0px"> <textarea style="outline-color: DEB441; margin-left: 23px; margin-bottom: 5px; overflow:auto;width:269px;height:15px;border:1px solid #DEB441;background:#fff;padding:3px 5px;color:#3D1E09;font:14px;font-style:italic;margin:0" name="cf_adres" rows="2" cols="20"></textarea> </td> </tr> <tr> <td><font color="FFFFFF">Telefon</td> <td style="padding:0px"> <textarea style="outline-color: DEB441; margin-left: 23px; margin-bottom: 5px; overflow:auto;width:269px;height:15px;border:1px solid #DEB441;background:#fff;padding:3px 5px;color:#3D1E09;font:14px;font-style:italic;margin:0" name="cf_telefon" rows="2" cols="20"></textarea> </td> </tr> <tr> <td><font color="FFFFFF">E-mail:</td> <td style="padding:0px"> <textarea style="outline-color: FFFFFF; margin-left: 23px; margin-bottom: 5px; overflow:auto;width:269px;height:15px;border:1px solid #DEB441;background:#fff;padding:3px 5px;color:#3D1E09;font:14px;font-style:italic;margin:0" name="cf_email" rows="2" cols="20"></textarea> </td> </tr> <tr> <td style="width: 150px;"> <p style="align: left; margin-top: 2px; margin-right: 10px;"><br> <font style="font-size: 16px;" color="#FFFFFF" align="left"> Wybierz produkty:<br><br> <font style="font-size: 12px;" color="#FFFFFF" align="left"> Herbatniki w pudelkach <br> <hr align="left" width="110px"><bt> <input type="checkbox" name="thenderese" value="thenderese" />Thenderese<br> <input type="checkbox" name="petipa" value="petipa" />Petipa<br> <input type="checkbox" name="biscripts" value="biscripts" />Biscripts<br> </p> </td> <td style="width: 150px;"> <p style="width: 250px; align: left;"><br> <font style="font-size: 12px;" color="#FFFFFF" align="left"> Herbatniki Pakowane pojedynczo<br> <hr align="left" width="160px"> <input type="checkbox" name="6g" value="g6g" />6g <input type="checkbox" name="150g" value="g150g" />150g <input type="checkbox" name="300g" value="g300g" />300g </p> </td> </tr> <tr> <td style="width: 200px; margin-right: 250px;"> <p align="left" style="align: left; margin-top:0px;"><br> <font style="font-size: 12px;" color="#FFFFFF" align="left"> Inne <hr align="left" width="150px"> <input type="checkbox" name="folia" value="folia">Biscripts opakowane w folie<br> <input type="checkbox" name="speculoos1" value="speculoos1" />1,5 kg (proszek speculoos)<br> <input type="checkbox" name="speculoos2" value="speculoos2" />1,1 kg (pokruszony speculoos)<br> <input type="checkbox" name="krem" value="krem biscripts" />krem biscripts<br> </p> </td> </tr> </table> </form> 

和我的PHP

 <?php $field_imie = $_POST['cf_imie']; $field_nazwisko = $_POST['cf_nazwisko']; $field_adres = $_POST['cf_adres']; $field_telefon = $_POST['cf_telefon']; $field_email = $_POST['cf_email']; $field_message = $_POST['cf_message']; $mail_to = 'serwis@reskomp.pl'; $subject = 'nowe zamowienie '.$field_imie; $body_message = 'Od: '.$field_imie."\\n"; $body_message .= 'Nazwisko: '.$field_nazwisko."\\n"; $body_message .= 'Adres: '.$field_adres."\\n"; $body_message .= 'Telefon: '.$field_telefon."\\n"; $body_message .= 'Email: '.$field_email."\\n"; $body_message .= 'Szczegoly zamowienia: '.$field_message; $thenderese = $_POST['thenderese']; if ($thenderese != 'Yes') { $thenderese = 'No'; } $petipa = $_POST['petipa']; if ($petipa != 'Yes') { $petipa = 'No'; } $biscripts = $_POST['biscripts']; if ($biscripts != 'Yes') { $biscripts = 'No'; } $g6g = $_POST['6g']; if ($g6g != 'Yes') { $g6g = 'No'; } $g150g = $_POST['150g']; if ($g150g != 'Yes') { $g150g = 'No'; } $g300g = $_POST['300g']; if ($g300g != 'Yes') { $g300g = 'No'; } $folia = $_POST['folia']; if ($folia != 'Yes') { $folia = 'No'; } $speculoos1 = $_POST['speculoos1']; if ($speculoos1 != 'Yes') { $speculoos1 = 'No'; } $speculoos2 = $_POST['speculoos2']; if ($speculoos2 != 'Yes') { $speculoos2 = 'No'; } $krem = $_POST['krem']; if ($krem != 'Yes') { $krem = 'No'; } $headers = 'From: '.$field_email."\\r\\n"; $headers .= 'Reply-To: '.$field_email."\\r\\n"; $mail_status = mail($mail_to, $subject, $body_message, $headers); if ($mail_status) { ?> <script language="javascript" type="text/javascript"> alert('Zamowienie zostalo przyjete do realizacji.'); window.location = '../herbatniki/index.html'; </script> <?php } else { ?> <script language="javascript" type="text/javascript"> alert('Blad wysylania wiadomosci. Prosimy o kontakt na adres: coo.maan@gmail.com'); window.location = 'Contacts.html'; </script> <?php } ?> 

如果有人可以帮助我...我知道我应该使用更多的CSS,但这不是原因。

您似乎无法提交表格。

此外,要将复选框数据添加到电子邮件中,可以使用类似以下的内容。

<?php
if($_SERVER['REQUEST_METHOD'] == 'POST') {
    var_dump($_POST);
    $message = '';
    $message .= sprintf("Name: %s\n", isset($_POST['name']) ? $_POST['name'] : '');
    $message .= sprintf("Foo wanted: %s\n", isset($_POST['foo']) ? 'Yes' : 'No');
    $message .= sprintf("Bar wanted: %s\n", isset($_POST['bar']) ? 'Yes' : 'No');
    var_dump($message);
}

?>

<form method="POST">
    Your Name:<input type="text" name="name" /><br />
    <input type="checkbox" name="foo" />You want Foo?<br />
    <input type="checkbox" name="bar" />You want Bar?<br />
    <input type="submit">
</form>

但是,请研究“ PHP中的电子邮件注入”。

您需要将内容添加到$body_message

更改

$thenderese = $_POST['thenderese'];
if ($thenderese != 'Yes') {
    $thenderese = 'No';
}

$thenderese = $_POST['thenderese'];
$body_message .= 'thenderese';
if ($thenderese != 'Yes') {
    $body_message .= 'No';
}
else {
    $body_message .= 'Yes';
}
$body_message .= '/n';

并继续执行其余的if语句。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM