obelizk
02-03-2012, 05:33 PM
Hey guys.
I'm having a lot of trouble trying to figure out why my contact form on my website isn't working. The layout of it looks great, and when I click send, a message pops up that says 'message sent,' but no e-mails go through to my e-mail. I'd appreciate help with this. I'm not the best at this stuff, but I've spent a couple hours trying to find out what was wrong, and really couldn't.
This is the HTML code for the contact form:
<div class="grid_6 alpha">
<form id="contact-form" method="post" name="contact-form" class="infield rounded-fields form-preset">
<p><span class="note">All fields are required!</span>
<p><label for="name">Your Name</label>
<input class="text" name="contact-names" type="text" id="name" />
<span class="name-required"></span></p>
<p><label for="phone">Your Phone</label>
<input class="text" name="contact-phone" type="text" id="phone" />
<span class="phone-required"></span></p>
<p><label for="email">Your Email</label>
<input class="text" name="contact-email" type="text" id="email" />
<span class="email-required"></span></p>
<p><label for="message" class="message-label">Message</label>
<textarea class="text-area" name="contact-comment" id="message"></textarea>
<span class="comment-required"></span></p>
<p><input class="send" id="submit-form" name="submit" type="submit" value="Send" /></p>
</form>
<div class="clear"></div>
</div>
and this is the PHP code:
<?php
$names = $_POST['names'];
$phone = $_POST['phone'];
$email = $_POST['email_address'];
$comment = $_POST['comment'];
$to ='MY EMAIL';
$message = "";
$message .= "*Name: " . htmlspecialchars($names, ENT_QUOTES) . "<br>\n";
$message .= "*phone: " . htmlspecialchars($phone, ENT_QUOTES) . "<br>\n";
$message .= "*Email: " . htmlspecialchars($email, ENT_QUOTES) . "<br>\n";
$message .= "Comment: " . htmlspecialchars($comment, ENT_QUOTES) . "<br>\n";
$lowmsg = strtolower($message);
$headers = "MIME-Version: 1.0\r\nContent-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: \"" . $names . "\" <" . $email . ">\r\n";
$headers .= "Reply-To: " . $email . "\r\n";
$message = utf8_decode($message); mail($to, "Note from the Contact Form", $message, $headers);
if ($message){
echo 'sent';
}else{
echo 'failed';
}
?>
Is there anything wrong with these?
I'm having a lot of trouble trying to figure out why my contact form on my website isn't working. The layout of it looks great, and when I click send, a message pops up that says 'message sent,' but no e-mails go through to my e-mail. I'd appreciate help with this. I'm not the best at this stuff, but I've spent a couple hours trying to find out what was wrong, and really couldn't.
This is the HTML code for the contact form:
<div class="grid_6 alpha">
<form id="contact-form" method="post" name="contact-form" class="infield rounded-fields form-preset">
<p><span class="note">All fields are required!</span>
<p><label for="name">Your Name</label>
<input class="text" name="contact-names" type="text" id="name" />
<span class="name-required"></span></p>
<p><label for="phone">Your Phone</label>
<input class="text" name="contact-phone" type="text" id="phone" />
<span class="phone-required"></span></p>
<p><label for="email">Your Email</label>
<input class="text" name="contact-email" type="text" id="email" />
<span class="email-required"></span></p>
<p><label for="message" class="message-label">Message</label>
<textarea class="text-area" name="contact-comment" id="message"></textarea>
<span class="comment-required"></span></p>
<p><input class="send" id="submit-form" name="submit" type="submit" value="Send" /></p>
</form>
<div class="clear"></div>
</div>
and this is the PHP code:
<?php
$names = $_POST['names'];
$phone = $_POST['phone'];
$email = $_POST['email_address'];
$comment = $_POST['comment'];
$to ='MY EMAIL';
$message = "";
$message .= "*Name: " . htmlspecialchars($names, ENT_QUOTES) . "<br>\n";
$message .= "*phone: " . htmlspecialchars($phone, ENT_QUOTES) . "<br>\n";
$message .= "*Email: " . htmlspecialchars($email, ENT_QUOTES) . "<br>\n";
$message .= "Comment: " . htmlspecialchars($comment, ENT_QUOTES) . "<br>\n";
$lowmsg = strtolower($message);
$headers = "MIME-Version: 1.0\r\nContent-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: \"" . $names . "\" <" . $email . ">\r\n";
$headers .= "Reply-To: " . $email . "\r\n";
$message = utf8_decode($message); mail($to, "Note from the Contact Form", $message, $headers);
if ($message){
echo 'sent';
}else{
echo 'failed';
}
?>
Is there anything wrong with these?