我正在尝试使用以下代码将用户选择的选项的值发送到电子邮件地址,但该值在发送后不会显示在电子邮件中。
这是我的表格:
$('#dark-toggle').click(function(){
//this gets executed each click so we need to toggle the boolean value.
if ($.cookie('darkModeOn')==0){
$.cookie('darkModeOn', 1, { expires: 7 });
}else{
$.cookie('darkModeOn', 0, { expires: 7 });
}
console.log( "cookie:"+$.cookie('darkModeOn')) ;
$('#test').toggleClass('dark-mode');
});
if ($.cookie('darkModeOn')){
//this is only executed on load
$('#test').toggleClass('dark-mode');
}
这是我的.php:
<!-- contact form -->
<form action="plugins/contact-form.php" method="post" class="form contact-form">
<div class="row clearfix">
<div class="col-1-3">
<label for="contact-name"><strong>Name</strong> (required)</label>
<input type="text" name="name" value="" id="contact-name" required>
</div>
<div class="col-1-3">
<label for="contact-email"><strong>Email</strong> (required)</label>
<input type="email" name="email" value="" id="contact-email" required>
</div>
<div class="col-1-3 last">
<label for="contact-www"><strong>Subject</strong></label>
<input type="text" name="subject" value="" id="contact-www">
</div>
</div>
<div class="row clearfix">
<div class="col-1-1">
<select name="feedback" id="feedback">
<option value="1">Volvo</option>
<option value="2">Saab</option>
<option value="3">Mercedes</option>
<option value="4">Audi</option>
</select>
</div>
<div class="col-1-1 last">
<label for="contact-message"><strong>Message</strong> (required)</label>
<textarea name="message" id="contact-message" cols="88" rows="6" required></textarea>
</div>
</div>
<input type="submit" value="Submit Comment" class="large invert">
<div class="clear"></div>
</form>
<!-- /contact form -->
答案 0 :(得分:0)
我认为错误就在这里:
$message = "$input_message\n";
$message .= "\n---\nThis email was sent by contact form.";
$feedback = "$feedback";
您应该将最后一行替换为:
$message .= $feedback;