php - contact form is blank; contact form reply goes to wrong address -
am trying make captcha-free, spam blocking contact form. user's point of view, appears working since thank-you page appears after send button clicked.
problem #1: email arrives blank, containing none of content of message sent. found post here sounds similar, suggestion offered didn't apply: contact form problem - receive messages, no contents (blank page).
problem #2: reply message shows in same inbox instead of being sent form user's address--which when testing, 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 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 actual address removed):
<?php if(isset($_post['url']) && $_post['url'] == ''){ $youremail = '----@----.com'; $body = "this form 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 problem in code above . . . or else going on?
you're trying access $_post['email']
while field's name email
(small "e") - try using $_post['email']
instead
second problem - mail()
function's first argument email onto want sent, i.e. $_post['email']
. right you're trying send hard-coded $youremail
.
Comments
Post a Comment