<p>
<?php

$PREposted = $_POST['submitContact'];

$opt = $_POST['opt'];

if (isset($PREposted)) {
$posted = $PREposted;
$error=false;

if (!empty($_POST['firstname'])) {
$firstname = $_POST['firstname'];
} // if empty name
else {
$error = true;
$errorFname = "Please leave your first name";
}//else empty name

if (!empty($_POST['surname'])) {
$surname = $_POST['surname'];
} // if empty name
else {
$error = true;
$errorSname = "Please leave your surname";
}//else empty name

if (!empty($_POST['email'])) {
$email = $_POST['email'];
}
else {
$error = true;
$errorEMAIL = "Please leave an email";
}

if (!empty($_POST['tel'])) {
$tel = $_POST['tel'];
} // if empty name
else {
$error = true;
$errorTEL = "Please leave a contact telephone number";
}//else empty name

if (!empty($_POST['message'])) {
$message = $_POST['message'];
}
else {
$error = true;
$errorMESSAGE = "Leave a message for us";
}

if ($error == true) {
JFactory::getApplication()->enqueueMessage("Ooops, something's not right. Fix the problems highlighted in red", 'error');
}
if (empty($error)) {
$headers="From: ".$email."\n";
$headers.='Content-type: text/html; charset=iso-8859-1';
$to = "
This email address is being protected from spambots. You need JavaScript enabled to view it. ";

$subject = "Message from Stunell Technologies";
$content = "
<html>
<head></head>
<body>
<p>New message from " . $firstname . " " . $surname . "</p>
<p>Their Email is - " . $email . "</p>" . "
<p>Their Number is - " . $tel. "</p>

<p>Their response to having their details stored for marketing purposes is - " . $opt . "</p>
<p>Additionally they said: \n " . $message . "</p>
</body>
</html>";
$sentmail = mail($to, $subject, $content, $headers);
if (isset($sentmail)) :
JFactory::getApplication()->enqueueMessage('Message Sent');

unset($firstname, $surname, $email, $tel, $opt, $message, $error, $posted);
endif;
}



}// end isset submit

?>







<?php if (isset($firstname)) :?>

<?php endif ?>
<?php if (isset($posted) && !isset($firstname)) : ?>

<?php endif ?>







<?php if (isset($surname)) :?>

<?php endif ?>
<?php if (isset($posted) && !isset($surname)) : ?>

<?php endif ?>







<?php if (isset($email)) :?>

<?php endif ?>
<?php if (isset($posted) && !isset($email)) : ?>

<?php endif ?>







<?php if (isset($tel)) :?>

<?php endif ?>
<?php if (isset($posted) && !isset($tel)) : ?>

<?php endif ?>

<?php if (isset($posted) && isset($tel)) {echo ' has-success' ;} ?>
<?php if (isset($posted) && !isset($tel)) {echo ' has-error' ;} ?>
<?php if (isset($posted)) {echo ' has-feedback';} ?>
">


Yes Please.

No Thank You.<br><br>

<?php if (isset($opt)) :?>

<?php endif ?>
<?php if (isset($posted) && !isset($opt)) : ?>

<?php endif ?>







<?php if (isset($message)) :?>

<?php endif ?>
<?php if (isset($posted) && !isset($message)) : ?>

<?php endif ?>












</p>