Am trying to make a captcha-free, spam blocking contact form. From the user's point of view, it appears to be working since the thank-you page appears after the send button is clicked.
Problem #1: The email that arrives is blank, containing none of the content of the message that was sent. Found a post here that sounds similar, but the suggestion offered didn't apply: Contact form problem - I do receive messages, but no contents (blank page).
Problem #2: The reply message also shows up in that same inbox instead of being sent to the form user's address--which when testing, is my own.
The HTML:
<form method="post" action="submit.php">
<p>Name:<br>
<input type="text" name="Name" id="Name" /></p>
<p>Phone:<br>
<input type="text" name="Phone" id="Phone" /></p>
<p>Email:<br>
<input type="text" name="Email" id="Email" /></p>
<p class="antispam">Leave this empty:<br />
<input name="url" /></p>
<p style="color:#06C;">Forward to:<br>
<input type="text" name="Forwardto" id="Forwardto" /></p>
<p>Message:<br />
<textarea name="Message" rows="20" cols="20" id="Message"></textarea></p>
<p><input type="submit" value="Send" class="submit-button" /></p>
</form>
The PHP (with my actual address removed):
<?php
if(isset($_POST['url']) && $_POST['url'] == ''){
$youremail = '----@----.com';
$body = "This is the form that was just submitted:
Name: $_POST[name]
Phone: $_POST[phone]
E-Mail: $_POST[email]
Forward to: $_POST[forwardto]
Message: $_POST[message]";
if( $_POST['email'] && !preg_match( "/[\r\n]/", $_POST['email']) ) {
$headers = "From: $_POST[email]";
} else {
$headers = "From: $youremail";
}
mail($youremail, 'Contact Form', $body, $headers );
}
?>
The relevant CSS:
<style type="text/css">
.antispam { display:none;}
</style>
Is the problem in the code above . . . or could something else be going on?