Hello. I have a form page that has been created with the fields: Name, Email, Phone (day), Phone (Eve), Address, and Comments. The form will need to be sent to an email address upon clicking the submit button. I have read some previous posts and tried using some of the code suggested with the code below being one that worked for another user. When I go to the testing server to test the form I get an htdocs/missing.htm page instead of the form being submitted or giving a form not submitted error message. Could there be a problem with the permissions of the file, or am I missing something with the code? Thanks.
Here is the code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> - City Hall Directory</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<form id="form1" method="post" action="<?php echo $me;?>">
<p><span class="style6">Name
</span><br />
<input name="textfield" type="text" class="form" />
</p>
<p><span class="style6">Email
</span><br />
<input name="textfield2" type="text" class="form" />
</p>
<p><span class="style6">Phone (day)
</span><br />
<input name="textfield3" type="text" class="form" />
</p>
<p><span class="style6">Phone (eve)
</span><br />
<input name="textfield4" type="text" class="form" />
</p>
<p><span class="style6">Address
</span><br />
<input name="textfield5" type="text" class="form" />
</p>
<p><span class="style6">Comments </span><br />
<textarea name="textfield6" cols="50" rows="10" class="form"></textarea>
</p>
<p> </p>
<p>
<input name="Submit" type="submit" class="form" value="Send" />
</p>
</form>
<?
$formgood = true;
$name = $_POST['Name'];
$email = $_POST['Email'];
$phone day = $_POST['Phone (day)'];
$phone eve = $_POST['Phone (eve)'];
$addfress = $_POST['Address'];
$comments = $_POST['comments'];
$to = "email@domainname.com"; //Please change this to your e-mail address
$message = "$name has submitted a contact form. \n\n $comments \n\n You can reply to $email";
//check to make sure all form elements were filled in
if ($name == "") {
echo 'You must provide your name to contact us. Please click the back, and try again';
$formgood = false;
}
if ($email == "") {
echo 'We require an e-mail address in order for us to respond. Please go back and try again.';
$formgood = false;
}
if ($comments == "") {
echo 'You must provide comments in order to submit this form. Please click back, and try again.';
$formgood = false;
}
if ($formgood) {
if(mail($to, "A contact us form has been submitted by $name", $message, "From: $email\n")) {
echo 'Thank you for submitting this form. We will review your comments and contact you shortly. <br>';
}
else
{
echo "An error has occured. Please contact the webmaster.";
}
}
else {
echo "<br> Please review the comments above and try again.";
}
?>
<p><br />
</p>
<p> </p>
<p>
</div>
<br />
<p> </p>
</div>
</div>
<!-- end #primaryContent -->
</div>
</script>
</body>
</html>