Contact Forms in Website

gumspitter

New Member
I have written a PHP script to handle the data in an email and made a thank you page to indicate to the user that the form was submitted properly. However, when I test the form on the contact form page the email does not come through to my email. Please help!!!Miller Web Designs


PHP Script
<?php

/* Subject and Email Variables */

$emailSubject = 'Someone is Interested in Miller Web Designs';
$webMaster = '[email protected]';

/* Gathering Data Variables */

$firstnameField = $_POST['firstname'];
$lastnameField = $_POST['lastname'];
$phoneField = $_POST['phone'];
$emailField = $_POST['email'];
$commentsField = $_POST['comments'];

$body = <<<EOD
<br><hr><br>
First Name: $firstname <br>
Last Name: $lastname <br>
Phone Number: $phone <br>
Email: $email <br>
Comments: $comments <br>
EOD;

$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster , $emailSubject, $body, $headers);

/*Results Rendered as HTML */

$theResults = <<<EOD
<html>
<head>
<title>Miller</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body {
background-color: #f1f1f1;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-style: normal;
line-height: normal;
font-weight: normal;
color: #666666;
text-decoration: none;
}
-->
</style>
</head>

<div>
<div align="left">Thank you for your interest! Your email will be answered very soon!</div>
</div>
</body>
</html>
EOD;
echo "$theResults";



?>

HTMl Code

<table width="60%" border="1" cellpadding="6" bgcolor="#091A2A">
<tr>
<td><form action="contactform.php" method="post">First Name:
<input name="firstname" type="text" id="firstname" size="15
" maxlength="20">
<br />
Last Name:
<input name="lastname" type="text" id="lastname" size="15
" maxlength="40">
<br />
Day Time Phone (before 5pm):
<input name="phone" type= "phone
" id="phone" value="xxx-xxx-xxxx" size="15"
maxlength="13">
<br />
Email Address:<input name="email" type= "name" id="email" size="40"
maxlength="50">
<br />

Brief Despription of Your proposed project (max 100 characters)<br />
<textarea name="comments" rows="6" id="comments"> </textarea>
<br />

<input name="submit" type="submit" id="submit" value="Send">
<input name="Reset" type="reset" value="Reset">
</form>


Thanks
 
Last edited:

onlinetraining

New Member
If the results message is displayed after the form is submitted then you most likely have an email sending issue.
Some servers prevents a script to send an email from an address not recognized by the web host or email provider. So instead of using your visitor's email address as the sender how about using a valid and verified email address with your domain name in it.

If for example your domain name is mysite.com and you have an email address [email protected] or [email protected] already created in your web hosting server email system, then you can use one of those email addresses instead.

You can learn more about it by looking into SPF (Sender Policy Framework). It's a way of fighting spam.
 
Top