PDA

View Full Version : Mailing php script problem


hummer2001
12-09-2008, 12:33 PM
Hi Guys,

Im attemting to make an online survey but for some reason my script is not being processed and I cant figure out why.

heres the php script :


<?PHP
/* Subject, Email Variables */

$emailSubject = 'Customer Survey Form';
$salesManager = 'xx@xx.com';
/* Customer details */
$tradeNameField = $_POST('tradename');
$emailField = $_POST('email');
$phoneField = $_POST('phone');

/* Hear About */

$hearAboutField = $_POST('hearAbout');
$publicationField = $_POST('publication');
$hearOtherTextAreaField = $_POST('hearOtherTextArea');

/* Why did you choose PSI */

$whyChooseField = $_POST('whyChoose');
$whyChooseOtherTextAreaField = $_POST('whyChooseOtherTextArea');

/* Satisfaction */

$mostSatisfiedField = $_POST('mostSatisfied');
$leastSatisfiedField = $_POST('leastSatisfied');

/* How would you rate the following */
$ConProField = $_POST('ConPro');
$DesignField = $_POST('Design');
$PresDrawField = $_POST('PresDraw');
$QuPrField = $_POST('QuPr');
$InstallationField = $_POST('Installation');
$ValMonField = $_POST('ValMon');
$FlexCusField = $_POST('FlexCus');
$SubConServField = $_POST('SubConServ');
$AfterSalSerField = $_POST('AfterSalSer');

/* Sector */

$SectorField = $_POST('Sector');
$SectorOtherTextFieldField = $_POST('SectorOtherTextField');

/* What Publications do you read */

$IndPublicationsField = $_POST('IndPublications');


/* What websites do you visit */

$IndWebField = $_POST('IndWeb');

/* Other Comments */

$OtherCommentsMainField = $_POST('OtherCommentsMain');

/* Subscribe to the newsletter */

$NewsletterSubscribeField = $_POST('NewsletterSubscribe');


$body = <<<EOD
<br><hr><br>
Trade Name : $tradename <br>
Email Adress : $email <br>
Phone Number : $phone <br>
Where did you hear about us : $hearAbout <br>
Name of publication : $publication <br>
Where did you hear about us other : $hearOtherTextArea <br>
Why did you choose us : $whyChoose <br>
Why did you choose us other reason : $whyChooseOtherTextArea <br>
What were you most satisfied with : $mostSatisfied <br>
What were you least satisfied with : $leastSatisfied <br>
Consultation Process : $ConPro <br>
Design : $Design <br>
Presentation of Drawings : $PresDraw <br>
Quality of Products : $QuPr <br>
Installation : $Installation <br>
Value for money : $ValMon <br>
Flexibility to customers : $FlexCus <br>
Sub-contract services : $SubConServ <br>
After Sales Service : $AfterSalSer <br>
What sector are you in : $Sector <br>
What sector if other : $SectorOtherTextField <br>
What industry publications do you read : $IndPublications <br>
What websites do you visit : $IndWeb <br>
Additional Comments : $OtherCommentsMain <br>
Subscribe to Newsletter : $NewsletterSubscribe <br>
EOD;
$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($salesManager, $emailSubject, $body, $headers);

/* Success !! */

$theResults = <<<EOD
<html>
<head>
<title>PSI Thanks for submitting</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 submission</div>
</div>
</body>
</html>
EOD;
echo "$theResults";

?>


Please note that ive changed the address in the script to 'xx@xx.com' on purpose to protect the identity of the person in question.

Apologies about it being a long form. I've gone thru it a few times but just cant seem to find my mistakes. Thanks for any input.

hummer2001
12-09-2008, 12:35 PM
The 1st bit of the form itself is here:


<!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=utf-8" />
<title>Prime Shop Interiors Customer Survey</title>
<style type="text/css">
<!--

#apDiv1 {
position:relative;
left:auto;
top:0px;
width:990px;
height:auto;
z-index:1;
background-color: #000000;
margin-top: 0px;
margin-right: auto;
margin-bottom: 0px;
margin-left: auto;
right: auto;
padding-left: 10px;
padding-right: 10px;
}
.logopic {
float: left;
padding-top: 15px;
}
.style1 {
color: #FFFFFF;
font-family: Arial, Helvetica, sans-serif;
}
.style2 {font-size: 18px}

.linkOne a {
color: red;
text-decoration: none;
}
.linkOne a:hover {
color: teal;
text-decoration: underline;
}
body {
background-color: #333333;
}
.style5 {color: #FFFFFF}
.style6 {
font-size: 24px;
font-weight: bold;
}

-->
</style>
</head>
<body>
<div id="apDiv1"><img src="supplierterms/PSILOGOBLACK.jpg" alt="PSI logo" width="200" height="97" class="logopic" />
<p align="left" class="style1"><br />
<span class="style2"><strong><br />
<br />
</strong></span></p>
<p align="left" class="style1">&nbsp;</p>
<p align="center" class="style1">&nbsp;</p>
<p align="center" class="style1"><span class="style6">PRIME SHOP INTERIORS CUSTOMER SURVEY</span></p>
<form id="form1" name="form1" method="post" action="customersurveyform.php">
<table width="100%" border="1" cellpadding="6" cellspacing="0" bordercolor="#333333">
<tr>
<td><div align="right">
<label for="tradename"><span class="style5">Trade Name (Optional):</span></label>
</div></td>
<td><div align="left">
<input name="tradename" type="text" id="tradename" size="35" maxlength="90" />
</div></td>
</tr>
<tr>
<td><div align="right">
<label for="email" class="style5">Email (Optional):</label>
</div></td>
<td><div align="left">
<input name="email" type="text" id="email" size="35" maxlength="90" />
</div></td>
</tr>
<tr>
<td><div align="right">
<label for="phone" class="style5">Telephone Number (Optional):</label>
</div></td>
<td><div align="left">
<input name="phone" type="text" id="phone" size="35" maxlength="12" />
</div></td>
</tr>
<tr>
<td><div align="right" class="style5">How did you hear of Prime Shop Interiors ?</div></td>
<td><div align="left">
<p>
<label>
<input type="radio" name="hearAbout" value="advertisement" id="hearAbout_0" />
<span class="style5"> Advertisement - Please state which publication: </span></label>
<label for="publication"></label>
<input name="publication" type="text" id="publication" size="30" maxlength="90" />
<br />
<label>
<input type="radio" name="hearAbout" value="internetSearch" id="hearAbout_1" />
<span class="style5">Internet Search</span></label>
<br />
<label>
<input type="radio" name="hearAbout" value="previousCustomer" id="hearAbout_2" />
<span class="style5 style5"> Previous Customer</span></label>
<br />
<label>
<input type="radio" name="hearAbout" value="referral" id="hearAbout_3" />
<span class="style5">Referral</span></label>
<br />
<label>
<input type="radio" name="hearAbout" value="tradeShow" id="hearAbout_4" />
<span class="style5">Trade Show</span></label>
<br />
<label>
<input type="radio" name="hearAbout" value="hearAboutOther" id="hearAbout_5" />
<span class="style5">Other - Please state:</span></label>
<br />
<label for="hearOtherTextArea"></label>
<textarea name="hearOtherTextArea" id="hearOtherTextArea" cols="70" rows="5"></textarea>
</p>
</div></td>
</tr>
<tr>
<td><div align="right" class="style5">Why did you choose Prime Shop Interiors to implement your project?</div></td>
<td><div align="left">
<p class="style5">
<label>
<input type="radio" name="whyChoose" value="design" id="whyChoose_0" />
Design</label>
<br />
<label>
<input type="radio" name="whyChoose" value="valueForMoney" id="whyChoose_1" />
Value for Money</label>
<br />
<label>
<input type="radio" name="whyChoose" value="qualityOfProduct" id="whyChoose_2" />
Quality of Product</label>
<br />
<label>
<input type="radio" name="whyChoose" value="deliverByDeadlines" id="whyChoose_3" />
Ability to deliver by deadlines</label>
<br />
<label>
<input type="radio" name="whyChoose" value="salesConsultant" id="whyChoose_4" />
Professionalism of Sales Consultant</label>
<br />
<label>
<input type="radio" name="whyChoose" value="whyChooseOtherReason" id="whyChoose_5" />
Other - Please state:</label>
<br />
<label for="whyChooseOtherTextArea"></label>
<textarea name="whyChooseOtherTextArea" id="whyChooseOtherTextArea" cols="70" rows="5"></textarea>
</p>
</div></td>
</tr>
<tr>
<td><div align="right">
<label for="mostSatisfied" class="style5">Which aspect of Prime Shop Interiors' service were you <strong>most</strong> satisfied with?</label>
</div></td>
<td><div align="left">
<textarea name="mostSatisfied" id="mostSatisfied" cols="70" rows="5"></textarea>
</div></td>
</tr>
<tr>
<td><div align="right" class="style5">
<label for="leastSatisfied">Which aspect of Prime Shop Interiors' service were you <strong>least</strong> satisfied with?</label>
</div></td>
<td><div align="left"><span class="style5">
<textarea name="leastSatisfied" id="leastSatisfied" cols="70" rows="5"></textarea>
</span></div></td>
</tr>
<tr>
<td><div align="right" class="style5">How would you rate the following:</div></td>
<td><div align="left"></div></td>
</tr>
<tr>
<td><div align="right" class="style5">Consultation Process:</div></td>
<td><div align="left">
<p class="style5">
<label>
<input type="radio" name="ConPro" value="Not Applicable" id="ConPro_0" />
Not Applicable</label>
<br />
<label>
<input type="radio" name="ConPro" value="Poor" id="ConPro_1" />
Poor</label>
<br />
<label>
<input type="radio" name="ConPro" value="Below Standard" id="ConPro_2" />
Below Standard</label>
<br />
<label>
<input type="radio" name="ConPro" value="Average" id="ConPro_3" />
Average</label>
<br />
<label>
<input type="radio" name="ConPro" value="Good" id="ConPro_4" />
Good</label>
<br />
<label>
<input type="radio" name="ConPro" value="Excellent" id="ConPro_5" />
Excellent</label>
<br />
</p>
</div></td>
</tr>
<tr>
<td><div align="right" class="style5">Design:</div></td>
<td><div align="left">
<p class="style5">
<label>
<input type="radio" name="Design" value="Not Applicable" id="Design_0" />
Not Applicable</label>
<br />
<label>
<input type="radio" name="Design" value="Poor" id="Design_1" />
Poor</label>
<br />
<label>
<input type="radio" name="Design" value="Below Standard" id="Design_2" />
Below Standard</label>
<br />
<label>
<input type="radio" name="Design" value="Average " id="Design_3" />
Average </label>
<br />
<label>
<input type="radio" name="Design" value="Good " id="Design_4" />
Good </label>
<br />
<label>
<input type="radio" name="Design" value="Excellent" id="Design_5" />
Excellent</label>
<br />
</p>
</div></td>
</tr>
<tr>
<td><div align="right" class="style5">Presentation of Drawings:</div></td>
<td><div align="left">
<p class="style5">
<label>
<input type="radio" name="PresDraw" value="Not Applicable" id="PresDraw_0" />
Not Applicable</label>
<br />
<label>
<input type="radio" name="PresDraw" value="Poor" id="PresDraw_1" />
Poor</label>
<br />
<label>
<input type="radio" name="PresDraw" value="Below Standard" id="PresDraw_2" />
Below Standard</label>
<br />
<label>
<input type="radio" name="PresDraw" value="Average" id="PresDraw_3" />
Average</label>
<br />
<label>
<input type="radio" name="PresDraw" value="Good" id="PresDraw_4" />
Good</label>
<br />
<label>
<input type="radio" name="PresDraw" value="Excellent" id="PresDraw_5" />
Excellent</label>
<br />
</p>
</div></td>
</tr>
<tr>
<td><div align="right" class="style5">Quality of Products:</div></td>
<td><div align="left">
<p class="style5">
<label>
<input type="radio" name="QuPr" value="Not Applicable" id="QuPr_0" />
Not Applicable</label>
<br />
<label>
<input type="radio" name="QuPr" value="Poor" id="QuPr_1" />
Poor</label>
<br />
<label>
<input type="radio" name="QuPr" value="Below Standard" id="QuPr_2" />
Below Standard</label>
<br />
<label>
<input type="radio" name="QuPr" value="Average" id="QuPr_3" />
Average</label>
<br />
<label>
<input type="radio" name="QuPr" value="Good" id="QuPr_4" />
Good</label>
<br />
<label>
<input type="radio" name="QuPr" value="Excellent" id="QuPr_5" />
Excellent</label>
<br />
</p>
</div></td>
</tr>
<tr>
<td><div align="right"><span class="style5">Installation</span>:</div></td>
<td><div align="left">
<p class="style5">
<label>
<input type="radio" name="Installation" value="Not Applicable " id="Installation_0" />
Not Applicable </label>
<br />
<label>
<input type="radio" name="Installation" value="Poor" id="Installation_1" />
Poor</label>
<br />
<label>
<input type="radio" name="Installation" value="Below Standard" id="Installation_2" />
Below Standard</label>
<br />
<label>
<input type="radio" name="Installation" value="Average" id="Installation_3" />
Average</label>
<br />
<label>
<input type="radio" name="Installation" value="Good" id="Installation_4" />
Good</label>
<br />
<label>
<input type="radio" name="Installation" value="Excellent" id="Installation_5" />
Excellent</label>
<br />
</p>
</div></td>
</tr>
<tr>
<td><div align="right" class="style5">Value for Money:</div></td>
<td><div align="left">
<p class="style5">
<label>
<input type="radio" name="ValMon" value="Not Applicable" id="ValMon_0" />
Not Applicable</label>
<br />
<label>
<input type="radio" name="ValMon" value="Poor" id="ValMon_1" />
Poor</label>
<br />
<label>
<input type="radio" name="ValMon" value="Below Standard" id="ValMon_2" />
Below Standard</label>
<br />
<label>
<input type="radio" name="ValMon" value="Average" id="ValMon_3" />
Average</label>
<br />
<label>
<input type="radio" name="ValMon" value="Good" id="ValMon_4" />
Good</label>
<br />
<label>
<input type="radio" name="ValMon" value="Excellent" id="ValMon_5" />
Excellent</label>
<br />
</p>
</div></td>
</tr>
<tr>
<td><div align="right" class="style5">Flexibility to Customers:</div></td>
<td><div align="left">
<p class="style5">
<label>
<input type="radio" name="FlexCus" value="Not Applicable" id="FlexCus_0" />
Not Applicable</label>
<br />
<label>
<input type="radio" name="FlexCus" value="Poor" id="FlexCus_1" />
Poor</label>
<br />
<label>
<input type="radio" name="FlexCus" value="Below Standard" id="FlexCus_2" />
Below Standard</label>
<br />
<label>
<input type="radio" name="FlexCus" value="Average" id="FlexCus_3" />
Average</label>
<br />
<label>
<input type="radio" name="FlexCus" value="Good" id="FlexCus_4" />
Good</label>
<br />
<label>
<input type="radio" name="FlexCus" value="Excellent" id="FlexCus_5" />
Excellent</label>
<br />
</p>
</div></td>
</tr>

hummer2001
12-09-2008, 12:36 PM
The 2nd bit of the form :


<tr>
<td><div align="right" class="style5">Sub-Contract Services:</div></td>
<td><div align="left">
<p class="style5">
<label>
<input type="radio" name="SubConServ" value="Not Applicable" id="SubConServ_0" />
Not Applicable</label>
<br />
<label>
<input type="radio" name="SubConServ" value="Poor" id="SubConServ_1" />
Poor</label>
<br />
<label>
<input type="radio" name="SubConServ" value="Below Standard" id="SubConServ_2" />
Below Standard</label>
<br />
<label>
<input type="radio" name="SubConServ" value="Average" id="SubConServ_3" />
Average</label>
<br />
<label>
<input type="radio" name="SubConServ" value="Good" id="SubConServ_4" />
Good</label>
<br />
<label>
<input type="radio" name="SubConServ" value="Excellent" id="SubConServ_5" />
Excellent</label>
<br />
</p>
</div></td>
</tr>
<tr>
<td><div align="right" class="style5">After Sales Service:</div></td>
<td><div align="left">
<p class="style5">
<label>
<input type="radio" name="AfterSalSer" value="Not Applicable" id="AfterSalSer_0" />
Not Applicable</label>
<br />
<label>
<input type="radio" name="AfterSalSer" value="Poor" id="AfterSalSer_1" />
Poor</label>
<br />
<label>
<input type="radio" name="AfterSalSer" value="Below Standard" id="AfterSalSer_2" />
Below Standard</label>
<br />
<label>
<input type="radio" name="AfterSalSer" value="Average" id="AfterSalSer_3" />
Average</label>
<br />
<label>
<input type="radio" name="AfterSalSer" value="Good" id="AfterSalSer_4" />
Good</label>
<br />
<label>
<input type="radio" name="AfterSalSer" value="Excellent" id="AfterSalSer_5" />
Excellent</label>
<br />
</p>
</div></td>
</tr>
<tr>
<td><div align="right" class="style5">Which sector are you involved in?</div></td>
<td><div align="left">
<p class="style5">
<label>
<input type="radio" name="Sector" value="Beauty Salon" id="Sector_0" />
Beauty Salon</label>
<br />
<label>
<input type="radio" name="Sector" value="Bookmakers" id="Sector_1" />
Bookmakers</label>
<br />
<label>
<input type="radio" name="Sector" value="Fashion" id="Sector_2" />
Fashion</label>
<br />
<label>
<input type="radio" name="Sector" value="Fast food/Restaurant" id="Sector_3" />
Fast food/Restaurant</label>
<br />
<label>
<input type="radio" name="Sector" value="Footwear" id="Sector_4" />
Footwear</label>
<br />
<label>
<input type="radio" name="Sector" value="Gift" id="Sector_5" />
Gift</label>
<br />
<label>
<input type="radio" name="Sector" value="Grocery" id="Sector_6" />
Grocery</label>
<br />
<label>
<input type="radio" name="Sector" value="Jewellers" id="Sector_7" />
Jewellers</label>
<br />
<label>
<input type="radio" name="Sector" value="Medical/Dental" id="Sector_8" />
Medical/Dental</label>
<br />
<label>
<input type="radio" name="Sector" value="Off Licence" id="Sector_9" />
Off Licence</label>
<br />
<label>
<input type="radio" name="Sector" value="Opticians" id="Sector_10" />
Opticians</label>
<br />
<label>
<input type="radio" name="Sector" value="Pharmacy" id="Sector_11" />
Pharmacy</label>
<br />
<label>
<input type="radio" name="Sector" value="Sector Other" id="Sector_12" />
Other - Please state:</label>
<label for="SectorOtherTextField"></label>
<input name="SectorOtherTextField" type="text" id="SectorOtherTextField" size="35" maxlength="90" />
<br />
</p>
</div></td>
</tr>
<tr>
<td><div align="right">
<label for="IndPublications" class="style5">Which industry publications do you regularly read?</label>
</div></td>
<td><div align="left">
<textarea name="IndPublications" id="IndPublications" cols="70" rows="5"></textarea>
</div></td>
</tr>
<tr>
<td><div align="right">
<label for="IndWeb" class="style5">Which industry websites do you visit frequently?</label>
</div></td>
<td><div align="left">
<textarea name="IndWeb" id="IndWeb" cols="70" rows="5"></textarea>
</div></td>
</tr>
<tr>
<td><div align="right">
<label for="OtherCommentsMain" class="style5">Other Comments:</label>
</div></td>
<td><div align="left">
<textarea name="OtherCommentsMain" id="OtherCommentsMain" cols="70" rows="5"></textarea>
</div></td>
</tr>
<tr>
<td><div align="right">
<label for="NewsletterSubscribe" class="style5">Would you like to subscribe to our FREE newsletter?</label>
</div></td>
<td><div align="left">
<input type="checkbox" name="NewsletterSubscribe" id="NewsletterSubscribe" />

</div></td>
</tr>
<tr>
<td><div align="right">
<label for="clear"></label>
<input type="reset" name="clear" id="clear" value="Clear Form" />
</div></td>

<td><div align="left">
<label for="submitform"></label>
<input type="submit" name="submitform" id="submitform" value="Submit" />
</div></td>
</tr>
</table>
</form>
<p align="center" class="style1"><img src="images/PSIFooter.jpg" width="990" height="158" /></p>
</div>
</body>
</html>


Thanks for any input.

2bz2p
12-09-2008, 07:23 PM
My best suggestion is to echo out your $_POST vars, so you know there catching as well as echoing some text to make sure your script is firing.

2b

hummer2001
12-09-2008, 09:37 PM
Hi 2bz2p (cool name btw :D im like that !!!)

When i press the submit button, the url changes to the .php file, but no html is shown and no email is sent. Would this information help to uncover the problem?

edbr
12-10-2008, 01:24 AM
ITS a good start to debug

2bz2p
12-10-2008, 06:05 PM
I would add a couple of echos into the php page before your html and email is called, then if you get to that point move up your echos, you have a larg script there and the issue could lie in there silently, like a ' you forgot or missed a letter when writing the variables out.

The other thing I find benficial is I will separate the code out into anothe page and make sure it fires off, then cut and copy it to the final page. I do this when I have switches and if statements in a function thats with in a class. This way I can get right to the root and its saves me time in the long run.

2b

hummer2001
12-11-2008, 05:23 PM
Found my problems :D

1st problem:

$tradeNameField = $_POST('tradename');

was using normal parenthesis instead of curly (don't you just love learning new programming languages!!!!)

2nd Problem:

In the $body (e.g.)

$body = <<<EOD
<br><hr><br>
Trade Name : $tradename <br>

I have $tradename, when it should be $tradenameField as I have it named earlier

Easy :)#

Thanks for the input guys you both got me thinking.