Contact Form - troubleshooting
I'm trying to use a contact form that I had implemented on a different website. I copied over the form from the contact page, and then I also copied the necessary data from the mailer.php that the form submission uses.
This isn't the first time I have copied and used this form, I am fairly familiar with it. However, this is the first time that I have had to add quite a few more fields to it and I think that may be where my problem lies, not quite sure.
Anyways, here are the chunks of code.
this is located on the contact-us.php page:
<form method="post" action="mailer.php">
<input class="input" name="recipient" type="hidden" id="recipient" value="****@gmail.com" />
<input name="subject_prefix" type="hidden" id="subject_prefix" value="Contact Form: " />
<tr style="vertical-align:top">
<td style="text-align:right;">Name:</td>
<td><input class="input" type="text" name="name" size="30" /></td>
</tr>
<tr style="vertical-align:top">
<td style="text-align:right;">City:</td>
<td><input class="input" type="text" name="city" size="30" /></td>
</tr>
<tr style="vertical-align:top">
<td style="text-align:right;">State:</td>
<td><input class="input" type="text" name="state" size="30" /></td>
</tr>
<tr style="vertical-align:top">
<td style="text-align:right;">Zip Code:</td>
<td><input class="input" type="text" name="zipcode" size="30" /></td>
</tr>
<tr style="vertical-align:top">
<td style="text-align:right;">Closest Major City:</td>
<td><input class="input" type="text" name="majorcity" size="30" /></td>
</tr>
<tr style="vertical-align:top">
<td style="text-align:right;">E-Mail:</td>
<td><input class="input" type="email" name="email" size="30" /></td>
</tr>
<tr style="vertical-align:top">
<td style="text-align:right;">Phone:</td>
<td><input class="input" type="tel" name="phone" size="30" /></td>
</tr>
<tr style="vertical-align:top">
<td style="text-align:right;">Contact Preference:</td>
<td><select class="input" size="1" name="contact_preference">
<option class="input" selected="selected">E-Mail</option>
<option class="input" >Telephone</option>
</select></td>
</tr>
<tr style="vertical-align:top">
<td style="text-align:right;">Contact Time:</td>
<td><select class="input" size="1" name="contact_time">
<option class="input" selected="selected">Morning</option>
<option class="input" >Afternoon</option>
<option class="input" >Evening</option>
</select></td>
</tr>
<tr style="vertical-align:top;">
<td style="text-align:right;">Message:</td>
<td><textarea class="textarea" style="resize:none;" rows="9" name="message" cols="33" ></textarea></td>
</tr>
<tr style="vertical-align:top">
<td></td>
<td><input class="submit" type="submit" value=" SUBMIT " name="submit" /></td>
</tr>
</form>
then on the mailer.php page I have:
<?php
$subject = $subject_prefix;
$body = "From: " . $name . "\n";
$body .= "----------------------------------\n";
$body .= "City: " . $city . "\n";
$body .= "----------------------------------\n";
$body .= "State: " . $state . "\n";
$body .= "----------------------------------\n";
$body .= "Zip Code: " . $zipcode . "\n";
$body .= "----------------------------------\n";
$body .= "Major City: " . $majorcity . "\n";
$body .= "----------------------------------\n";
$body .= "Email: " . $email . "\n";
$body .= "----------------------------------\n";
$body .= "Phone Number: " . $phone . "\n";
$body .= "----------------------------------\n";
$body .= "Contact Preference: " . $contact_preference . "\n";
$body .= "----------------------------------\n";
$body .= "Contact Time: " . $contact_time . "\n";
$body .= "----------------------------------\n";
$body .= "Message: \n" . $message . "\n";
$header = "From: \"" . $name . "\" <" . $email . ">\n";
if( mail($recipient, $subject, $body, $header) ){
echo "The form you entered has been submitted. Thank you, $name, for your interest in **** ";
echo "Contact <a href=\"mailto:****@gmail.com\">****</a> if you would like further assistance.";
} else {
echo "There was an error sending the data.<br /> ";
echo "Please contact **** here at <a href=\"mailto:****@gmail.com\">****@gmail.com</a> with your information.";
}
?>
it consistenly throws back the else error, but as far as I can tell, everything is there that should allow the if statement to succede.
Please let me know if you see what I am doing wrong.
