我正在为简报设置一个选择列表。下面是我的PHP脚本,它正在运行,但是当我收到电子邮件时,我无法在邮件中看到电子邮件地址,只有这样:
电子邮件:
如何让电子邮件变量显示在电子邮件中?
编辑:我使用jquery / ajax发布表单,这就是为什么表单中没有帖子和操作。
PHP (newsletter.php)
<?php
$to = "newsletter@example.com";
$subject = "Send me the newsletter";
$email = $_POST['email'];
$email = filter_var($email , FILTER_SANITIZE_EMAIL);
$message = "Email: $email";
mail($to, $subject, $message, "From: no-reply@example.com");
?>
HTML
<form id="newsletter_signup">
<input type="text" name="email" id="email" placeholder="Email Address" /><input type="submit" value="Submit" class="submit_button" />
</form>
的jQuery
$.ajax({
type: "POST",
url: "newsletter.php",
data: $("input#email").val(),
success: function() {
$('#signup').html("<div id='message'></div>");
$('#message').html("<h3>Blah, blah, blah!</h3>")
.css({color:"#00000", fontFamily: "Arial", fontSize: "12px"})
.hide()
}
});
答案 0 :(得分:1)
试试这个:
$.ajax({
type: "POST",
url: "newsletter.php",
data: {"email" : $("input#email").val()},
success: function() {
$('#signup').html("<div id='message'></div>");
$('#message').html("<h3>Blah, blah, blah!</h3>")
.css({color:"#00000", fontFamily: "Arial", fontSize: "12px"})
.hide()
}
});
同时查看jQuery序列化方法(您只需键入data: $("form").serialize()
)。
http://api.jquery.com/serialize/
答案 1 :(得分:0)
你的来自
<form id="newlsetter_signup" method="POST" action="">