我在PHP的電子郵件的形式,我想一個主題添加到郵件正文:主題字段添加到PHP電子郵件的形式
<?php
if (isset($_POST["submit"])) {
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = 'Camino Contact Form';
$to = '[email protected]';
$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:我的表單中的主題字段是可選的,不需要驗證。
http://stackoverflow.com/a/6670067/2889187 –