我需要將選定的下拉值存入我的.php文件,該文件實際上是發送郵件文件。如何將下拉值存入.php文件
當我從下拉列表中選擇6個選項中的一個時,我想要選擇的選項作爲電子郵件的「主題」包含在郵件中。
這裏是我的HTML代碼
<span class="custom-dropdown big">
<select id="mounth" name="mounth">
<option value="default">-- Domain name --</option>
<option value="value1" rel="icon-temperature">value1</option>
<option value="value2">value2</option>
<option value="value3">value3</option>
<option value="value4">value4</option>
<option value="value5">value5</option>
<option value="value6">value6</option>
</select>
<input type="hidden" id="changeme" name="changeme" />
</span>
通過電子郵件形式
<div class="modal fade" id="popup-moda">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span id="spanhide" aria-hidden="true">×</span></button>
<h4 class="modal-title">Contact Us</h4>
</div>
<form action="" method="post" name="form" id="forms">
<div class="modal-body">
<div id="domain" name="domain"></div>
<input required id="name" name="name" placeholder="Name" type="text">
<input required id="email" name="email" placeholder="Email" type="text">
<textarea id="msg" name="msg" placeholder="Message"></textarea>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Send</button>
<div id="success" style="color: blue;"></div>
</div>
</form>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
這裏是我的JS代碼,實際上顯示選定的選項,但只作爲文本發送電子郵件之前 。
$(document).ready(function(){
$('.popup').click(function(e){
e.preventDefault();
$('#domain').html('<b>' + $('#mounth').val() + '</b>');
$('#popup-moda').modal('show');
return false;
});
});
我的PHP文件
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$msg = $_POST['msg'];
$to = '[email protected]';
$subject = 'New Customer Enquiry';
$msg = <<<EMAIL
Subject: $subject
Message: $msg
From: $name
Email: $email
EMAIL;
$headers = 'From:' . $email;
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
mail($to, $subject, $msg, $headers); mail.
echo "Thank you for your email! We will reply as soon as possible.";
}
else
{
echo "Invalid Email, please provide a correct email address.";
}
?>
謝謝你們。任何輸入是讚賞!
您可以使用AJAX。 –
有太多可能的答案,或者對於這種格式,答案太長。請添加詳細信息以縮小答案集或隔離可以在幾個段落中回答的問題。我建議您找到一個開發論壇(可能是[reddit](https://www.reddit.com/)?)找出共性。然後,當您遇到特定的編碼問題時,請回到StackOverflow,我們很樂意提供幫助。 –