Hello all,
I'm having trouble with a contact form I use on one of my sites. The fields include Name, Email Address, Phone Number, and Comments. Whenever I fill out the fields and press submit my confirmation page shows fine, but I never receive the info to my email address. My code is as follows:
my contact page,
HTML Code:
<form action="mailer.php" method="post">
<fieldset>
<legend> Contact Us</legend>
<ol>
<li>
<label for="name">Name</label>
<input id="name" name="name" class="text" type="text" />
</li>
<li>
<label for="email"> Email address </label>
<input id="email" name="email" class="text" type="text" />
</li>
<li>
<label for="phone"> Phone Number</label>
<input id="phone" name="phone" class="text" type="text" />
</li>
<li>
<label for="for""comments">Comments</label>
<textarea name="comments" cols="50" rows="2" wrap="virtual" class="text" id="comments"></textarea>
</li>
</ol>
</fieldset>
<fieldset class="submit">
<input class="submit" type="submit"
value="Submit" />
</fieldset>
</form>
mailer.php
PHP Code:
<?php
if(isset($_POST['submit'])) {
$to = "tim@yahoo.com";
$subject = "Website Comments";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$phone_field = $_POST['phone'];
$comments = $_POST['comments'];
$body = "From: $name_field\n E-Mail: $email_field\n Phone Number: $phone_field\n Comments:\n $comments";
echo "Data has been submitted to $to!";
mail($to, $subject, $body);
} else {
echo "Thanks for your message!";
}
?>
Thanks for any help
Bookmarks