<!DOCTYPE html>
<html lang="en"><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="JaviteSoft - Open source and code examples">
    <meta name="author" content="JaviteSoft">

    <title>JaviteSoft - Contact</title>

    <!-- Bootstrap core CSS -->
    <link href="css/bootstrap.css" rel="stylesheet">

    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <link href="css/ie10-viewport-bug-workaround.css" rel="stylesheet">

    <link href="css/global.css" rel="stylesheet">
    <link rel="icon" href="favicon.ico">
    <link rel="apple-touch-icon" href="apple-touch-icon.png"/>
    <link rel="apple-touch-icon-precomposed" href="apple-touch-icon.png"/>
  </head>

  <body>

    <a name="top"></a>
    <div class="main-masthead fixed-nav-bar">
      <div class="container">
        <nav class="main-nav">
          <a class="main-nav-item" href="index.php">Home</a>
          <a class="main-nav-item" href="projects.php" title="View the projects in development">Projects</a>
          <a class="main-nav-item" href="snippets.php" title="View the code snippets library">Snippets</a>
          <a class="main-nav-item" href="depends.php" title="Download any dependencies required">Dependencies</a>
          <a class="main-nav-item active" href="contact.php" title="Contact JaviteSoft">Contact</a>
          <a class="main-nav-item" href="about.php" title="About JaviteSoft">About</a>
        </nav>
      </div>
    </div>

    <div class="container">

      <div class="main-header">
        <h1 class="main-title">Contact JaviteSoft</h1>
        <p class="lead main-description">Send us a message.</p>
      </div>

      <div class="row">

        <div class="col-sm-8 main-main">

          <div class="main-post">

<?php

    
require("includes/contact.php");

    if (isset(
$_POST["submit"]))
    {
        
$name $_POST['name'];
        
$email $_POST['email'];
        
$message $_POST['message'];
        
$human intval($_POST['human']);
        
        
$body "From: $name\n E-Mail: $email\n Message:\n $message";
 
        
// Check if name has been entered
        
if (!$_POST['name']) {
            
$errName 'Please enter your name';
        }
        
        
// Check if email has been entered and is valid
        
if (!$_POST['email'] || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
            
$errEmail 'Please enter a valid email address';
        }
        
        
//Check if message has been entered
        
if (!$_POST['message']) {
            
$errMessage 'Please enter your message';
        }

        
//Check if simple anti-bot test is correct
        
if ($human !== 5) {
            
$errHuman 'Your answer is incorrect';
        }

        
// If there are no errors, send the email
        
if (!$errName && !$errEmail && !$errMessage && !$errHuman)
        {
            if (
mail($contact_to$contact_subject$body$contact_from))
            {
                
$result '<div class="alert alert-success">Thank You for your message.</div>';
            }
            else
            {
                
$result '<div class="alert alert-danger">Sorry there was an error sending your message. Please try again later</div>';
            }
        }
    }
?>

            <p>

<form class="form-horizontal" role="form" method="post" action="contact.php">
    <div class="form-group">
        <label for="name" class="col-sm-2 control-label">Name</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" id="name" name="name" placeholder="First & Last Name" value="<?php echo htmlspecialchars($_POST['name']); ?>">
            <?php echo "<p class='text-danger'>$errName</p>";?>
        </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" id="email" name="email" placeholder="example@domain.com" value="<?php echo htmlspecialchars($_POST['email']); ?>">
            <?php echo "<p class='text-danger'>$errEmail</p>";?>
        </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" rows="4" name="message"><?php echo htmlspecialchars($_POST['message']);?></textarea>
            <?php echo "<p class='text-danger'>$errMessage</p>";?>
        </div>
    </div>
    <div class="form-group">
        <label for="human" class="col-sm-2 control-label">2 + 3 = ?</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" id="human" name="human" placeholder="Your Answer">
            <?php echo "<p class='text-danger'>$errHuman</p>";?>
        </div>
    </div>
    <div class="form-group">
        <div class="col-sm-10 col-sm-offset-2">
            <input id="submit" name="submit" type="submit" value="Send" class="btn btn-primary">
        </div>
    </div>
    <div class="form-group">
        <div class="col-sm-10 col-sm-offset-2">
            <?php echo $result?>    
        </div>
    </div>
</form>

            </p>
            <hr>
          </div><!-- /.main-post -->
        </div><!-- /.main-main -->

      </div><!-- /.row -->

    </div><!-- /.container -->

    <footer class="main-footer">
      <p>Copyright &copy; 2015 JaviteSoft. All Rights Reserved.</p>
      <p>
        <a href="#top">Back to top</a>
      </p>
      <p>
        <a href="contact.phps"><small>View page source</small></a>
      </p>
    </footer>


    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="js/jquery.js"></script>
    <script src="js/bootstrap.js"></script>
    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <script src="js/ie10-viewport-bug-workaround.js"></script>
    <!-- Fix for local page links -->
    <script src="js/fix_anchors.js"></script>
  
</body>
</html>