简体   繁体   English

从表单发送带有html的html电子邮件

[英]html email with php from form

I have a review page that pulls data from a form like this 我有一个审核页面,该页面从这样的表单中提取数据

echo (!empty($_REQUEST['FW15LieAngle'])) ? "<div class='reviewItem'><span class='reviewTitle'>15.5 Lie Angle:</span>{$_REQUEST['FW15LieAngle']}</div>" : "";

so if they did pick that option it wont display on the form. 因此,如果他们选择了该选项,它将不会显示在表单上。 At the end of the review page I send all the data to the mail.php file like so: 在查看页面的末尾,我将所有数据发送到mail.php文件,如下所示:

<form method="post" action="priceorder.php">
            <ul>
            <?php


                if (is_array($_REQUEST)) {
                    foreach ($_REQUEST as $key => $val) {

                        // This code should support the checkboxes and multiple selects
                        if (is_array($val)) {
                            foreach ($val as $val2) {
                                echo "<input type='hidden' name='" . $key . "[]' value='" . $val2 . "' />";
                            }
                        }
                        else {
                            echo "<input type='hidden' name='" . $key . "' value='" . $val . "' />";
                        }
                    }
                }
            ?>
            </ul>
            <input name="submit" type="submit" value="" onclick="verify();" class="submit"/>
        </form>

in the mail.php file I would get the data from the review.php like so for a HTML email: 在mail.php文件中,我将从review.php中获取数据,就像HTML电子邮件一样:

<div class='reviewItem'><span class='reviewTitle'>15.5 Lie Angle:</span>".$_REQUEST['FW15LieAngle']."</div>

This works fine but I would like it to work like the review page in that if this option had zero data it wouldnt show in the email. 这可以正常工作,但我希望它可以像查看页面那样工作,如果该选项的数据为零,则不会在电子邮件中显示。 I tried adding the php like in the review.php but the email wont work. 我试图像在review.php中那样添加php,但是电子邮件无法正常工作。 Any ideas or if it can be done so that if that field has no data it wont show in the HTML email??? 任何想法或是否可以做到的,如果该字段没有数据,则不会显示在HTML电子邮件中???

append the email body like this: 像这样添加电子邮件正文:

if (!empty($_REQUEST['FW15LieAngle'])){
    $emailBody.="<div class='reviewItem'><span class='reviewTitle'>15.5 Lie Angle:</span>".$_REQUEST['FW15LieAngle']."</div>";
}

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

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