<?php $_ENV['PATH_INFO'];
?>
  <!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <title>Dallas Architects | How to Reach Us</title>
  
  <link rel="stylesheet" type="text/css" href="css/main.css"/>
  <script src='https://www.google.com/recaptcha/api.js'></script>

</head>
<body><script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-55275908-1', 'auto');
  ga('send', 'pageview');

</script>
<div class="page-container"><h1 style="text-align: center;"><span class="logo">Kirk & Associates</span></h1>
  <div class="header-wrapper">
    <header>
      <ul>
        <li><a href="index.html">Home</a></li>
        <li><a href="about_us.html">About Us</a></li>
        <li><a href="portofolio_recent_works.html">Portfolio</a></li> <li><a href="affiliations.html">Affiliations</a></li>
 <li><a href="contact_us.php">Contact Us</a></li>
  

      </ul>
    </header>
  </div>
  <div class="content-container">

    
    <center><br/>
      How To Reach Us<br/>
      Phone, Fax, E-mail and Address
    </center><br/>

    <div class="center wide">
      <section class="services"><article><p>
        <span class="contact">Robert Dyrel Kirk III, CEO</span><br/>
        AIA ASID NCARB<br/>
        E-Mail: KirkArch1@aol.com <br>
      </p>

      <p>
        <span class="contact">Address:</span><br/>
        5931 Greenville Ave #772<br/>
        Dallas, Texas 75206
      </p>

      <p>
        <span class="contact">Telephone:</span><br/>
        Office: (214)-368-5057<br/>
        Cell: (214)-912-7642
      </p>

      <p>
        <span class="contact">Fax:</span><br/>
        (214)-368-3941
   </p>
   </article>
   <article>
      <p> <span class="contact">Contact Form:</span></p>
  <p>  
<script>
function validateForm() {
    var x = document.forms["form"]["name"].value;
    if (x==null || x=="") {
        alert("First name must be filled out");
        return false;
    }



    var x = document.forms["form"]["email"].value;
    var atpos = x.indexOf("@");
    var dotpos = x.lastIndexOf(".");
    if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length) {
        alert("Not a valid e-mail address");
        return false;
    }
}
</script>

<?php

if ( !isset( $_POST['submit'] ) ) {
?>
<form method="post" name="submit" action="<?php echo $_SERVER['PHP_SELF']; ?>">
 <table width="100%" border="0">
  <tr>
    <td>Name<input type="text" name="Name" id="Name" value="" placeholder="Your Name" required></td>
  </tr>
  <tr>
    <td>Email<input type="text" name="Email" id="Email" value="" placeholder="Your email address" required /></td>
  </tr>
  <tr>
    <td>Phone<input type="text" name="Phone" id="Phone" value="" size="30" required></td>
  </tr>
  <tr>
    <td>Message<textarea  cols="50" name="Message" id="message" maxlength="250"></textarea></td>
  </tr>
</table>
<div class="g-recaptcha" data-sitekey="6LcLHYUUAAAAAJMh1KpZjwt4m5uxeFtIXuMAKKUb"></div>

<input type="submit" value="SEND" id="submit" name="submit" class="btn btn-prime btn-full"/>
    </form>
<?php
} else { 
	define('DB_HOST', 'localhost');
	define('DB_NAME', 'kirkarch_contacts');
	define('DB_USER','kirkarch_contact');
	define('DB_PASSWORD','Ou813Ou813');

	$con=mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) or die("Failed to connect to MySQL: " . mysql_error());
	$db=mysql_select_db(DB_NAME,$con) or die("Failed to connect to MySQL: " . mysql_error());
	//inserting Record to the database

	mysql_set_charset( 'utf8', $con);


	$name = $_POST['Name'];
	$email = $_POST['Email'];
	$phone = $_POST['Phone'];
	$message = $_POST['Message'];
	$creationDate = time();



  $response = $_POST["g-recaptcha-response"];
  $url = 'https://www.google.com/recaptcha/api/siteverify';
  $data = array(
    'secret' => '6LcLHYUUAAAAAIBS9NhdDg_kdVVykFtcWZogDapr',
    'response' => $_POST["g-recaptcha-response"]
  );
  $options = array(
    'http' => array (
      'method' => 'POST',
      'content' => http_build_query($data)
    )
  );
  $context  = stream_context_create($options);
  $verify = file_get_contents($url, false, $context);
  $captcha_success=json_decode($verify);
  if ($captcha_success->success==false) {
    echo "<p>You are a bot! Go away!</p>";
  } else if ($captcha_success->success==true) {
    //echo "<p>You are not not a bot!</p>";
  
  	$query = "INSERT INTO contact ( creationDate, contactName, contactEmail, contactPhone, message ) VALUES ( $creationDate, '$name', '$email', '$phone', '$message')";
  	$result = mysql_query($query, $con);
  	if( !$result )
  		echo 'An error occured saving your message in database.';

  	mysql_close($con);

  	//Email information
  	$from = 'info@kirkarchitecture.com';
    $to = 'kirkarch1@kirkarchitecture.com';
  	$subject = "Website Contact";
  	$message = "Name: $name\r\n Email: $email\r\nMessage: $message\r\n";
  	$headers = "From: $from\r\n";
	$bcc = 'mark@webixlc.com';


  	$result = mail($to, $subject, $message, $headers, $bcc);
   
  	//Email response
  	if( $result )
  		echo '<h2>Thank you, we will respond in 24 to 48 business hours!</h2>';
  	else
  		echo 'An error occured during message sending. Please try again later or contact support using phone.';
  }





}
?>


</article></section>
    </div>

  </div>
</div>
<div class="sticky-footer">
  <div class="footer-wrapper">
    <footer>
      
      <ul class="links">
                <li><a href="index.html" class="link_color">home</a></li>
    <li><a href="about_us.html" class="link_color">about us</a></li>
	<li><a href="portofolio_recent_works.html" class="link_color">portfolio</a></li>      
    <li><a href="affiliations.html" class="link_color">affiliations</a></li>
	<li><a href="contact_us.php" class="link color">contact us</a></li>
    
          </ul><div class="copyright">Copyright &copy;2014 Kirk and Associates Architects</div>
      <div class="location">Dallas, Texas &nbsp; Tel: (214)-368-5057</div>
        </footer>
  </div>
</div>
</body>
</html>