i have problem getting data mail form being sent correctly in email. strange email message.
original form message:
enter name: fake name enter email address: fake.name@doesnotexist.com enter message: email test number 4(four). submit _____________________________________________
the email message received:
from: <fake.name@doesnotexist.com> subject: <new form submission> reply to: <warnerheston@sungraffix.net> to: me <web289portfolio@sungraffix.net> _____________________________________________ have received new message user fake name. here message: email test number 4(four).web289portfolio@sungraffix.net _____________________________________________
the email in message body "(four).web289portfolio@sungraffix.net" , underlined/hyperlinked... strange!!
it not supposed have email address in message body @ all. user did not type email address @ end of message. somehow, php code dropping destination email address message body , attaching last "word" of user's message email adress when sends it.
can tell me doing wrong?
<?php if(!isset($_post['submit'])) { //this page should not accessed directly. need submit form. echo "error; need submit form!"; } $name = $_post['name']; $visitor_email = $_post['email']; $message = $_post['message']; //validate first if(empty($name)||empty($visitor_email)||empty($message)) { header('location: contact-form-incomplete.html'); exit; } if(isinjected($visitor_email)) { echo "bad email value!"; exit; } $email_from = $_post['email']; //<== update email address $email_subject = "new form submission"; $email_body = "you have received new message user $name.\n". "here message:\n $message". $to = "web289portfolio@sungraffix.net";//<== update email address $headers = "from: $email_from \r\n"; $headers .= "reply-to: $visitor_email \r\n"; //send email! mail($to,$email_subject,$email_body,$headers); //done. redirect thank-you page. header('location: contact-thankyou.html'); // function validate against email injection attempts function isinjected($str) { $injections = array('(\n+)', '(\r+)', '(\t+)', '(%0a+)', '(%0d+)', '(%08+)', '(%09+)' ); $inject = join('|', $injections); $inject = "/$inject/i"; if(preg_match($inject,$str)) { return true; } else { return false; } } ?>
this html form:
<form method="post" name="myemailform" action="form-to-email.php"> <p> <label for='name'><span class='form'>enter name:</span></label><br> <input type="text" name="name" size="36"> </p> <p> <label for='email'><span class='form'>enter email address:</span></label><br> <input type="email" name="email" size="36"> </p> <p> <label for='message'><span class='form'>enter message:</span></label> <br> <textarea name="message" cols='48' rows='9' maxlength='300'></textarea> </p> <input type="submit" name='submit' value="submit"> <input type="reset"> </form>
look @ code on $email_body
, concatenate $email_body
$to
. concatenation .
@ end of $email_body
should ;
.
Comments
Post a Comment