【发布时间】:2011-06-28 05:52:44
【问题描述】:
目前我正在制作一个在线查询表格,其中包含一组非必填字段。
如果未填写非必填表单字段,我希望它不会出现在已处理的电子邮件中。
例如;如果有人不输入他们的电话号码,则“电话:$atelephone”组件不会通过。
if ($atelephone != '') {
echo "Telephone: ".$atelephone;
}
我认为代码中应该包含与上面类似的内容,尽管我正在努力连接这些点。任何帮助将不胜感激。 (我希望这是有道理的)。
<?php
// Base form items
$asender = $HTTP_POST_VARS['name'] ." <". $HTTP_POST_VARS['email'] .">";
$asubject = "Email Enquiry: ".$HTTP_POST_VARS['subject'];
$arecipient = "recipient@websiteaddress.com.au";
/*******************************************************/
// Mail form variables //
$aname = $HTTP_POST_VARS['name'];
$aemail = $HTTP_POST_VARS['email'];
$atelephone = $HTTP_POST_VARS['telephone'];
$asuburb = $HTTP_POST_VARS['suburb'];
$aenquiry = $HTTP_POST_VARS['enquiry'];
mail("$arecipient","$asubject",
"
===========================================
Please note: this is an email
generated from the Website.
===========================================
Name: $aname
Email: $aemail
Telephone: $atelephone
Suburb: $asuburb
Message:
$aenquiry
================================ ","FROM:$asender");
header('Location: /thank-you.php');
?>
【问题讨论】: