<?php

  // process form
  if (@$_REQUEST['submitForm']) {

    // error checking
    $errorsAndAlerts = "";
    if (!@$_REQUEST['fullname'])               { $errorsAndAlerts .= "You must enter your full name!<br/>\n"; }
    if (!@$_REQUEST['edit'])                   { $errorsAndAlerts .= "You must enter your email!<br/>\n"; }
    else if(!isValidEmail(@$_REQUEST['edit'])) { $errorsAndAlerts .= "Please enter a valid email (example: user@example.com)<br/>\n"; }
    if (!@$_REQUEST['message'])                { $errorsAndAlerts .= "You must enter a message!<br/>\n"; }

    if (!$errorsAndAlerts) {

	    // Send Admin Alert via Email Template
			$emailHeaders = emailTemplate_loadFromDB(array(
			    'template_id'  => 'CONTACT-FORM-TO-ADMIN',
			    'placeholders' => array(
			      'user.name'     => $_REQUEST['fullname'],
			      'user.email'    => $_REQUEST['edit'],
			      'user.comment'  => $_REQUEST['message'],
			
			  )));
			$mailErrors   = sendMessage($emailHeaders);
	    // Send Admin Alert via Email Template
			$emailHeaders = emailTemplate_loadFromDB(array(
			    'template_id'  => 'CONTACT-FORM-TO-USER',
			    'placeholders' => array(
			      'user.name'     => $_REQUEST['fullname'],
			      'user.email'    => $_REQUEST['edit'],
			      'user.comment'  => $_REQUEST['message'],
			
			  )));
			$mailErrors   = sendMessage($emailHeaders);
	
	      // 
	      $errorsAndAlerts = "Thanks!  We've sent your email.";
	      $_REQUEST = array(); // clear form values
    }
  }

?><div class="row"><div class="col-xs-12">
	<form method="POST" action=""  class="form-horizontal"  role="form"/>
	<input type="hidden" name="submitForm" value="1" >
	<input type="text" name="email" style="display:none;" >

<div class="row"><div class="col-xs-12"><div class="form-group">
	<label for="fullname" class="col-sm-2 control-label">Full Name</label>
	<div class="col-sm-10">
		<input type="text" class="form-control"  name="fullname" id="fullname" placeholder="Your Name" value="<?php echo htmlspecialchars(@$_REQUEST['fullname']); ?>">
	</div>
</div>

<div class="form-group">
	<label for="email" class="col-sm-2 control-label">Email</label>
	<div class="col-sm-10">
		<input type="email" class="form-control"  name="edit" id="edit" placeholder="Your Email" value="<?php echo htmlspecialchars(@$_REQUEST['edit']); ?>">
	</div>
</div>

<div class="form-group">
	<label for="message" class="col-sm-2 control-label">Message</label>
	<div class="col-sm-10">
		<textarea class="form-control" id="message" name="message" rows="3"><?php echo htmlspecialchars(@$_REQUEST['message']); ?></textarea>
	</div>
</div>

<p class="text-right">
	<button type="submit" class="btn btn-default">Submit</button>
</p>
</div>
</div>
</form>
</div>
</div>