Skip to main content
Participant
July 16, 2008
Question

Contact Form help

  • July 16, 2008
  • 4 replies
  • 441 views
When I test my contact form at my webpage, instead of sending the email, it redirects to the php form I'm using when I click the "send" button. For the properties, I have it set as this for the form: "Action:ESFContactForm.php, Method:POST."

Here's my php code...I changed some info to keep things private for my client:

<?php

/* Subject and Email variables */

$emailSubject = '';
$webMaster = 'name@site.com';

/* Gathering Date Variables */

$nameField = $_POST['name'];
$biznameField = $_POST['bizname'];
$addressField = $_POST['address'];
$cityField = $_POST['city'];
$stateField = $_POST['state'];
$zipcodeField = $_POST['zipcode'];
$phoneField = $_POST['phone'];
$emailField = $_POST['email'];
$commentsField = $_POST['comments'];

$body = <<<EOD
<br><hr><br>
Your Name: $name <br>
Business Name: $bizname <br>
Street Address: $address <br>
City: $city <br>
State: $state <br>
Zip: $zipcode <br>
Phone: $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>Titled Added Here</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body {
background-color: #BCBCBC;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-style: normal;
line-height: normal;
font-weight: normal;
color: #000000;
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";


?>
This topic is closed to new replies. Start a new post to keep the conversation going.

4 replies

Participant
July 17, 2008
Could you help me a little more on this please?
July 17, 2008
You do not need a database for this. You need the form to be set to process itself, and then you need to put a header command in once the mail sends with a redirect in it.

they are formatted like this:

header("Location: [url goes here]");

Make sure this is AFTER your mail script, and wrapped in an if statement that only processes it if your mail is sent.
Participant
July 17, 2008
Another add...someone mentioned I need a "database" as told by PHPesp - what is that?
Participant
July 17, 2008
Add-on...when I click the submit button, it tries to read the php page as if it was a page such as html, then gives me a "cannot find this page" error message. I have the submit button in a form box with the PHP file name in the "Action."