小编Tyl*_*aft的帖子

你能在php电子邮件中插入一个if语句吗?

// 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']; } ]

但它似乎没有实际工作...任何想法?

php email if-statement

0
推荐指数
1
解决办法
1320
查看次数

标签 统计

email ×1

if-statement ×1

php ×1