【发布时间】:2015-07-19 17:31:43
【问题描述】:
我有一个 PHP 电子邮件表单,我想在电子邮件正文中添加一个主题:
<?php
if (isset($_POST["submit"])) {
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = 'Camino Contact Form';
$to = 'emailo@example.com';
$subject = 'Message from Camino.bo ';
$body ="From: $name\n E-Mail: $email\n Message:\n $message";
// If there are no errors, send the email
if (!$errName && !$errEmail && !$errMessage) {
if (mail ($to, $subject, $body, $from)) {
$result='<div class="success">Thank You! I will be in touch</div>';
} else {
$result='<div class="danger">Sorry there was an error sending your message. Please try again.</div>';
}
}
}
?>
此表单提交主题为“来自 Camino.bo 的消息”的电子邮件,没关系,但我想在电子邮件正文中提交用户从下拉菜单中选择的值:
HTML:
<select name="subject" id="email_subject">
<option value="default subject">Select a subject</option>
<option>Product A</option>
<option>Product B</option>
<option>Product C</option>
</select>
我该怎么做? PS:我的表单中的主题字段是可选的,不需要验证。
【问题讨论】:
标签: php html email contact-form