PDA

View Full Version : Contact Form not Working


JonnyJ
06-02-2009, 04:09 PM
Hey guys...I'm having an odd problem with my php script for a simple contact form. I've done this 3-4 times before, and have never had this problem. I have the script set up to send the information to an email address. I see all of the sections I want emailed, but the php is not picking up what the user types in on the website. here is the script


<?php

/* Subject and Email variables */

$emailSubject = 'WebsiteContact!';
$webMaster = 'jonjaszek@colorblinddesigner.com';

/* Gathering Data Variables */

$nameField = $_POST['name'];
$phoneField = $_POST['phone'];
$emailField = $_POST['email'];
$guestsField = $_POST['guests'];
$rentalchoiceField = $_POST['rentalchoice'];
$checkinField = $_POST['checkin'];
$commentsField = $_POST['comments'];


$body = <<<EOD
<br><hr><br>
Name: $name <br>
Phone Number: $phone <br>
Email Address: $email <br>
Number of Guests: $guests <br>
Rental Choice: $rentalchoice <br>
Check-in Date: $checkin <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
<link href="Css/Richaven.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
#ThankYou {
height: 350px;
width: 350px;
margin-right: auto;
margin-left: auto;
background-image: url(Images/Stock/thanks.png);
background-repeat: no-repeat;
background-position: right bottom;
background-color: #FFFFFF;
margin-top: 5px;
padding-left: 10px;
}
.style1 {
font-size: 18px;
font-family: Georgia, "Times New Roman", Times, serif;
color: #6dad37;
font-weight: bold;
}
.style2 {
color: #6dad37;
font-weight: bold;
}
-->
</style>
</head>

<body>

<div id="ThankYou">
<p>&nbsp;</p>
<p>&nbsp;</p>
<p class="style1">Thank You</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
Thank you for your interest in Richaven <br />
Cottages! We will recieve your email<br />
shortly and respond as soon<br /> as we can. If you would prefer you <br />
may contact us via phone at your <br/> convenience. <br /><br /><br />
<span class="style2">Summer</span> - (603) 524-7704 <br />
<span class="style2">Winter</span> - (413) 583-3132</div>

</body>
</html>
EOD;
echo "$theResults";


?>


anyone have any idea whats wrong? the page where the user submits the info is here

http://richavencottages.com/Reservations.html

I also made a quick test page to see if it was the html and now the php that was wrong which was here

http://richavencottages.com/test.html

either page yields the same results.

thanks in advance

davidj
06-02-2009, 04:59 PM
where you have this


$success = mail($webMaster, $emailSubject, $body, $headers);



you don't need to assign it to a variable

comment the mail function out and echo each variable in the email function call in turn

like this...


echo $webMaster;

//mail($webMaster, $emailSubject, $body, $headers);



run the script and check each var contains what you expect

The next step is to replace the vars with actual strings in the email call

then test its actually sending emails