html - PHP Contact Form Not Being Received In Email -
i know there few of these posts up, , read through them, unable find solution problem. php , html looks not sure why not receiving email submitted contact form.
here php:
<?php $fname = $_post ['fname']; $lname = $_post ['lname']; $email = $_post ['email']; $message = $_post ['message']; $to = 'myname@mywebsite.com'; $subject = 'contact website'; $msg = " first name: $fname/n" . "last name: $lname/n" . "email: $email/n" . "message: $message"; mail ($to, $subject, $msg,"from: " . $fname . $lname); $confirm = "thank contacting us! please allow 48 hours representative respond. click <a href='contact.php'>here</a> return previous page."; ?>
and here html form code:
<form id="form1" name="form1" method="post" action="send.php"> <tr> <label><td width="160px" class="labels">first name: </td> <td class="input"><input type="text" name="fname" id="fname"/></td> </label> </tr> <tr> <label><td class="labels">last name: </td> <td class="input"><input type="text" name="lname" id="lname"/></td> </label> </tr> <tr> <label><td class="labels">email: </td> <td class="input"><input type="email" name="email" id="email"/></td> </label> </tr> <tr> <label><td class="labels">message: </td> <td class="input"><textarea name="message" id="message" cols="30" rows="5"></textarea></td> </label> </tr> <tr> <td class="labels"><input type="submit" name="submit" id="submit" value="submit"/></td> </tr> </form>
any apreciated
edit:
there many errors.
improper use of \n
, mail()
headers , trying echo
success message @ end.
here tested , working mail handler script.
note: added if{isset
condition.
change email@example.com
own e-mail address.
<?php if(isset($_post['submit'])) $fname = $_post['fname']; $lname = $_post['lname']; $email = $_post['email']; $message = $_post['message']; $to = "email@example.com"; // <<< change own e-mail address $subject = "contact website"; $msg = "first name: $fname\n" . "last name: $lname\n" . "email: $email\n" . "message: $message"; $headers = "from: $email" . "\r\n" . "reply-to: $email" . "\r\n" . "x-mailer: php/" . phpversion(); mail($to, $subject, $msg, $headers); echo "thank contacting us! please allow 48 hours representative respond. click <a href='contact.php'>here</a> return previous page."; ?>
supplement
please read on mail( )
function , proper use of headers visiting:
there plenty of examples on page.
one major error use of /n
, need changed \n
if anything.
that alone make handler fail.
Comments
Post a Comment