<?php
if(isset($_POST['email'])) {
     
    // CHANGE THE TWO LINES BELOW
    $email_to = "courtney@courtneysemeniuk.com";
     
    $email_subject = "website html form submissions";
     
     
    function died($error) {
        // your error code can go here
        echo "We are very sorry, but there were error(s) found with the form you submitted. ";
        echo "These errors appear below.<br /><br />";
        echo $error."<br /><br />";
        echo "Please go back and fix these errors.<br /><br />";
        die();
    }
     
    // validation expected data exists
    if(!isset($_POST['first_name']) ||
        !isset($_POST['email']) ||
		!isset($_POST['comments']) ||
        !empty($_POST['website'])) {
        died('We are sorry, but there appears to be a problem with the form you submitted.');       
    }
     
    $first_name = $_POST['first_name']; // required
    $email_from = $_POST['email']; // required
    $comments = $_POST['comments']; // required
    $spam = $_POST['website'];
	 
    $error_message = "";
    $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
  if(!preg_match($email_exp,$email_from)) {
    $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  }
    $string_exp = "/^[A-Za-z .'-]+$/";
  if(!preg_match($string_exp,$first_name)) {
    $error_message .= 'The Name you entered does not appear to be valid.<br />';
  }
  if(strlen($comments) < 2) {
    $error_message .= 'The Comments you entered do not appear to be valid.<br />';
  }
  if(!empty($spam)) {
	  $error_message .= 'you\'ve entered something in a hidden field thats intended to catch spammers:<br/> '.$spam.'<br/>leave this field blank if you can see it and everything should work fine.';
	  }
  
  
  if(strlen($error_message) > 0) {
    died($error_message);
  }
    $email_message = "Form details below.\n\n";
     
    function clean_string($string) {
      $bad = array("content-type","bcc:","to:","cc:","href");
      return str_replace($bad,"",$string);
    }
     
    $email_message .= "First Name: ".clean_string($first_name)."\n";
    $email_message .= "Email: ".clean_string($email_from)."\n";
    $email_message .= "Comments: ".clean_string($comments)."\n";
     
     
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);  
?><!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>Courtney Semeniuk - Thankyou for contacting me!</title>
<!--[if IE]>
		<link rel="stylesheet" type="text/css" href="style/ie.css" />
        <style type="text/css">
   body { behavior: url("scripts/csshover3.htc"); }
  </style>
		<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
	<![endif]-->
     <!--[if lt IE 7]>  
<link href="scripts/pngsupport.css" rel="stylesheet" type="text/css" />
<![endif]-->
<!-- Add fancyBox -->
<link rel="stylesheet" href="scripts/fancybox/source/jquery.fancybox.css?v=2.1.5" type="text/css" media="screen" />
<link href="style/pagestyle.css" rel="stylesheet" type="text/css" />

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="scripts/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
<script type="text/javascript" src="scripts/site.js"></script>



<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-22643977-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>

</head>

<body>

<div class="container">
<header class="row">
<h1>Courtney Semeniuk <span>design &middot; photography &middot; motion</span></h1>


<a href="#main" class="skip">Skip navigation</a>
<div class="navwrap col">
<nav id="nav-primary" class="">
<h3 id="menu">menu</h3>
<ul>
<li ><a href="index.html">About</a></li><li ><a href="web.html">Web Design</a></li><li><a href="print.html">Print Design</a></li><li><a href="photo.html">Photography</a></li><li><a href="video.html">Motion</a></li><li class="current"><a href="#contact" >Contact</a></li></ul>
</nav>

<nav class="social">
<a href="https://www.facebook.com/cs.design.photography.motion" class="fb"></a><a href="http://www.linkedin.com/profile/view?id=105379500" class="linked"></a><a href="https://twitter.com/c_semeniuk" class="twitter"></a><a href="https://www.youtube.com/channel/UC7OUXFK-6D9FHc9sXwZG8Mg" class="youtube"></a>
</nav>

</div>
</header>



<div class="row col">
<h2>Thank <span>You</span></h2>
<div class="col span_8"><p>I'll respond to your email as soon as possible.</p>
<p>In the mean time why don't you look through my galleries if you haven't already. Check out my social media sites and enjoy your day!</p>


</div>


</div>

</div>

</div>
<!--        FOOTER         !-->
<div class="clr"></div>
<div class="footer">
<div class="footerbg">
<div class="container">

<div class="row">
<div class="col span_5">
<a id="contact"></a>
<h2>Do you like<span> what you see?</span></h2>
<p>Drop me a line, tell me your wants and needs. Get some free advice and even a free quote on any services you require.</p>
<ul>
<li>Phone:<br />519.312.6907</li>
<li>email:<br /><a href="mailto:courtney@courtneysemeniuk.com" class="mob">moc.kuinemesyentruoc@yentruoc</a></li>
</ul>
</div>

<div class="col span_5">
<nav class="social">
<a href="https://www.facebook.com/cs.design.photography.motion" class="fb"></a><a href="http://www.linkedin.com/profile/view?id=105379500" class="linked"></a><a href="https://twitter.com/c_semeniuk" class="twitter"></a><a href="https://www.youtube.com/channel/UC7OUXFK-6D9FHc9sXwZG8Mg" class="youtube"></a>
</nav>

<form name="htmlform" method="post" action="html_form_send.php">

  <label for="first_name">Name </label>

  <input id="first_name" type="text" name="first_name" maxlength="50" size="30" placeholder="What do you call yourself?">

  <label for="email">Email Address </label>

  <input id="email"  type="email" name="email" maxlength="80" size="30" placeholder="Just so I can reply to you">

  <label for="comments">Comments </label>

  <textarea id="comments" name="comments" maxlength="1000" cols="25" rows="6" placeholder="I'd love to hear everythign you have to say."></textarea>
  
   <input  type="text" id="website" name="website" maxlength="80" size="30" style="display:none;" placeholder="if you can see this leave it blank">

  <input class="button" type="submit" value="Submit">

</form>


</div>

</div>

</div>
</div>
</div>


</body>
</html>

<?php
}
die();
?>