Page 1 of 1

Quick Form Processing Problem

Posted: Fri Sep 10, 2010 12:56 pm
by Maxwellink
Hello all,

I have ran into a problem with my php file that processes my contact form. Simply put, I cannot get the form to show up in my email.

Here is the code for the form process:

Code: Select all

<?php

/* Subject and email variables */

	$emailSubject = 'Contact from Website';
	$webMaster = 'zack.maxwell@ad-vancemedia.com';
	
	
/* gathering data variables */

 	$nameField = $_POST['name'];
	$emailField = $_POST['email'];
	$messageField = $_POST['message'];
	
	
	
	
	$body = <<<EOD
<br><hr><br>
Name: $nameField <br>
Email: $emailField <br>
Message: $messageField <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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<META HTTP-EQUIV="refresh" CONTENT="3;URL=http://www.packingandshippingstore.com/test/">
<title>Thanks for your contact!</title>
</head>

<body>


<br>
<p><h3>Your information had been successfully sent!</h3></p>
<br>
<p>Thank you for contacting the Packing & Shipping Specialists</p>
<br>
<p>You are about to be redirected to our <b>home</b> page.</p>
</align>
</body>
</html>	
EOD;

echo "$theResults";	
	
	
?>
I have used this EXACT same format on other clients forms without much hassle. After several days of brewing on the problem I've come to the conclusion I am doing something wrong, but cannot figure out what.

Here is the html for the form:

Code: Select all

<div id="contact">
				
				<form id="contact" name="contact" method="post" action="formprocess.php">
				  <table>
                    <tr>
                      <td><label for="firstname">name</label></td>
                      <td><input type="text" name="firstname" id="firstname" /></td>
                    </tr>
                    <tr>
                      <td><label for="email">email</label></td>
                      <td><input type="text" name="email" id="email" /></td>
                    </tr>
                    <tr>
                      <td><label for="message">message</label></td>
                      <td><textarea name="message" id="message"></textarea></td>
                    </tr>
                    <tr>
					  <td></td>
					  <td align="right"><input name="submit" type="submit" class="submit" value="   Submit   " id="submit" /></td>
                    </tr>
                  </table>
			  </form><!---end form--->
			</div><!---end contact form--->
Again, I've compared both pieces of code to multiple clients forms I've made with no avail. I have also tried multiple emails (including a yahoo account) so I don't think it's the email client. Any help is greatly appreciated. Thanks guys!

~Z

Re: Quick Form Processing Problem

Posted: Fri Sep 10, 2010 6:11 pm
by mecha_godzilla
Ok, a couple of points:

1. In your form, you have a text field called 'firstname' but you're trying to capture it as 'name' in the script.

2. I can't work out where in your message all the html code is being generated from. Presumably, all of the code (including your form values) need to be in the $body variable, so you need to check that where you're using

Code: Select all

$body = <<<EOD
<br><hr><br>
Name: $nameField <br>
Email: $emailField <br>
Message: $messageField <br>
EOD;
maybe it needs to be

Code: Select all

$body .= <<<EOD
<br><hr><br>
Name: $nameField <br>
Email: $emailField <br>
Message: $messageField <br>
EOD;
I would also avoid using EOD for the moment - just format everything in the $body variable as one line for the moment.

HTH,

Mecha Godzilla