// from the form
$name = trim(strip_tags($_POST['name']));
$email = trim(strip_tags($_POST['email']));
$message = htmlentities($_POST['message']);
// set here
$subject = "Contact form submitted!";
$to = 'your@email.com';
$body = HTML
$message
HTML;
$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
// send the email
mail($to, $subject, $body, $headers);
// redirect afterwords, if needed
header('Location: thanks.html');
Run Code Online (Sandbox Code Playgroud)
问题是,天气与否,你可以在html电子邮件正文中插入php if语句或在其中添加它的最佳方式.我正在创建详细的广告资源,一旦提交,就需要通过电子邮件发送到电子邮件.但我不想通过电子邮件发送完整的库存(包括空输入),它应该只通过电子邮件发送除了0之外的字段.我在想:
if ($armChair > 0) { echo 'Arm Chairs: ' . $_POST['armChair']; } ]
但它似乎没有实际工作...任何想法?