I am setting up an opt-in list for a newsletter. Below is my php script, which is working, but when I receive the email, I can't see the email address in the message, only this:
Email:
How can I get the email variable to display in the email message?
Edit: I'm posting the form using jquery/ajax, that's why there's no post and action in the form.
PHP (newsletter.php)
<?php
$to = "[email protected]";
$subject = "Send me the newsletter";
$email = $_POST['email'];
$email = filter_var($email , FILTER_SANITIZE_EMAIL);
$message = "Email: $email";
mail($to, $subject, $message, "From: [email protected]");
?>
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()
}
});