File: /home/slyfwmm/foar/wp-content/themes/flexfit/page-contact.php
<?php
/*
Template Name: Contact
*/
?>
<?php
/* ---------------------------------------------------- */
/* Error Handling */
/* ---------------------------------------------------- */
$nameError ="";
$emailError ="";
$commentError ="";
if(isset($_POST['submitted'])) {
if(trim($_POST['contactName']) === '') {
$nameError = 'Name';
$hasError = true;
} else {
$name = trim($_POST['contactName']);
}
if(trim($_POST['email']) === '') {
$emailError = 'Email';
$hasError = true;
} else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['email']))) {
$emailError = 'Email';
$hasError = true;
} else {
$email = trim($_POST['email']);
}
if(trim($_POST['comments']) === '') {
$commentError = 'Message';
$hasError = true;
} else {
if(function_exists('stripslashes')) {
$comments = stripslashes(trim($_POST['comments']));
} else {
$comments = trim($_POST['comments']);
}
}
if(!isset($hasError)) {
$emailTo = of_get_option('contact_email');
if (!isset($emailTo) || ($emailTo == '') ){
$emailTo = get_option('admin_email');
}
$subject = 'Contact Form from '.$name;
$body = "Name: $name \n\nEmail: $email \n\nComments: $comments";
$headers = 'From: '.$name.' <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email;
mail($emailTo, $subject, $body, $headers);
$emailSent = true;
}
} ?>
<?php get_header(); ?>
<div id="page" class="border-top clearfix">
<div id="subtitle">
<h1><?php the_title(); ?></h1>
<div id="breadcrumb"></div>
<div class="hr4"><span class="seperator"></span><span class="lightborder"></span></div>
</div>
<div id="content-full" class="page-contact">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" class="post">
<?php if(isset($emailSent) && $emailSent == true) { ?>
<div id="subtitle">
<h1><?php _e('Thanks for your message.', 'framework'); ?></h1>
<div id="breadcrumb"><?php the_breadcrumb(); ?></div>
<div class="hr4"><span class="seperator"></span><span class="lightborder"></span></div>
</div>
<h3><?php _e('Grazie, la tua email รจ stata inviata correttamente.', 'framework'); ?></h3>
<?php } else { ?>
<?php the_content(); ?>
<div class="clear"></div>
<div class="three_fourth last">
<form action="<?php the_permalink(); ?>" id="contactform" method="post">
<?php if($nameError != '') { ?>
<label for="contactName"><span class="error"><?php echo $nameError; ?></span></label>
<?php } else { ?>
<label for="contactName"><?php _e('Nome', 'framework'); ?></label>
<?php } ?>
<input type="text" name="contactName" id="contactName" value="<?php if(isset($_POST['contactName'])) echo $_POST['contactName'];?>" class="required requiredField" />
<?php if($emailError != '') { ?>
<label for="email"><span class="error"><?php echo $emailError;?></span></label>
<?php } else { ?>
<label for="email"><?php _e('Email', 'framework'); ?></label>
<?php } ?>
<input type="text" name="email" id="email" value="<?php if(isset($_POST['email'])) echo $_POST['email'];?>" class="required requiredField email" />
<?php if($commentError != '') { ?>
<label for="contactName"><span class="error"><?php echo $commentError;?></span></label>
<?php } else { ?>
<label for="contactName"><?php _e('Messaggio', 'framework'); ?></label>
<?php } ?>
<textarea name="comments" id="comments" rows="10" cols="30" class="required requiredField"><?php if(isset($_POST['comments'])) { if(function_exists('stripslashes')) { echo stripslashes($_POST['comments']); } else { echo $_POST['comments']; } } ?></textarea>
<input type="submit" id="submit" value="<?php _e('Invia Email', 'framework') ?>" />
<input type="hidden" name="submitted" id="submitted" value="true" />
<div class="clear"></div>
</form>
</div>
<div class="one_fourth">
<?php echo of_get_option('contact_text'); ?>
</div>
<?php } ?>
</div>
<?php endwhile; endif; ?>
</div>
</div>
<?php get_footer(); ?>