ok, I (once again) made an update to the script, so let me know if its sound
here it is
<?php
/*
Template Name: Bobs Contact Form
*/
?>
<?php get_header(); ?>
<div class="map">
<iframe width="480" height="494" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=Napolitano+Realty,+939+Orange+Avenue,+Coronado,+CA+92118-2609&aq=2&sll=37.0625,-95.677068&sspn=40.409448,93.076172&ie=UTF8&hq=Napolitano+Realty,&hnear=939+Orange+Ave,+Coronado,+San+Diego,+California+92118&ll=32.686543,-117.179229&spn=0.006295,0.006295&output=embed"></iframe>
</div>
<?php
$hasError = false;
$name = $_POST['contactName'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$comments = $_POST['comments'];
//If the form is submitted
if(isset($_POST['submitted']))
{
//Check to make sure that the name field is not empty
if(empty($name)) {
$formError[0] = 'You forgot to enter your name.';
$hasError = true;
}
//Check to make sure sure that a valid email address is submitted
if(!filter_var($email, FILTER_VALIDATE_EMAIL))
{
$formError[1] = 'You entered an invalid email address.';
$hasError = true;
}
//Check to make sure comments were entered
if(empty($comments))
{
$formError[2] = 'You forgot to enter your comments.';
$hasError = true;
}
//If there is no error, send the email
if(!isset($hasError)) {
echo 'email sent';
$to= 'lukemaxpro@excite.com';
$subject = 'Contact Form Submission from '.$name;
$body = 'Name: '.$name." \n\n".'Email: '.$email." \n\n".'Phone: '.$phone." \n\n".'Comments: '.$comments;
$headers = 'From: My Site <'.$to.'>' . "\r\n" . 'Reply-To: ' . $email;
$emailSent = mail($to, $subject, $body, $headers);
}
if($emailSent) {
?>
<div class="thanks">
<h1 style="text-transform: none;">Thanks, <?=$name;?></h1>
<p>Your email was successfully sent. I will be in touch soon.</p>
</div>
<?php }
} else { ?>
<div class="contact-form" style="padding:25px; float:left; margin-top: 50px; background-color: rgba(195,166,96,.13); height: 444px; width: 400px;">
<h1 style="text-align:center; margin-left: -25px; margin-top: -25px; width: 420px; color: white; font: 700 30px/1.1 georgia,'times new roman','sans-serif'; text-transform: uppercase;">Contact Form</h1>
<form action="<?php the_permalink(); ?>" id="contactForm" method="post">
<ol class="forms" style="margin-top:25px; width:400px; clear:none; margin-left:0">
<li><label for="contactName">Name</label>
<input type="text" name="contactName" id="contactName" class="requiredField" />
<?php if(empty($formError[0])) { ?>
<span class="error"><?php echo $formError[0]; ?></span>
<?php } ?>
</li>
<li><label for="email">Email</label>
<input type="text" name="email" id="email" class="requiredField email" />
<?php if(empty$formError[1])) { ?>
<span class="error"><?php echo $formError[1]; ?></span>
<?php } ?>
</li>
<li><label for="phone">Phone</label>
<input type="text" name="phone" id="phone" />
</li>
<li class="textarea"><label for="commentsText">Comments</label>
<textarea name="comments" id="commentsText" rows="10" cols="30" class="requiredField" style="height:150px"></textarea>
<?php if(empty(($formError[2])) { ?>
<span class="error"><?php echo $formError[3]; ?></span>
<?php } ?>
</li>
<li class="buttons"><input type="hidden" name="submitted" id="submitted" value="true" />
<button type="submit" style="float: right; padding-top: 9px; padding-bottom: 8px; padding-left: 6px; padding-right: 6px; font-family: georgia, 'times new roman',sans-serif;
background-color: #F47D3B; color: white; text-transform:uppercase">Submit</button></li>
</ol>
</form>
</div>
<?php
}
?>
<?php get_footer(); ?>
First, I instanciate all the variables (and the ones submitted from the form).
Then I heck if the $name field has been filled out, if it hasn't assign a value to the array $formError[0] and set a value to $hasError
Then check if the email address is valid, if it isn't set a valur to $formError[1] and set a value to $hasError
Then I check to see if any comments have been filled out, if it hsnt, set a value to $formError[2] and also to $hasError
If all three fields are good, then check if the $formError variable has been set, if it hasnt, send an email to me with mail()
Then I check if the email has been sent,and if it has I output athank you div.
Finally if the form hasn't been submitted I display a form (which check if those 3 fields have been filled out along the way.
Thanks...