Last active
December 16, 2015 23:29
-
-
Save JBreit/5513837 to your computer and use it in GitHub Desktop.
Contact page with a working form that validates that the user not only entered in correct user information but also is not a spam bot trolling the internet.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$action = (isset($_POST['__action'])) ? $_POST['__action'] : null; // is the action we have to take | |
$err = array(); // empty array to hold any processing errors | |
if($action){ // there is an action | |
if($action == 'Send'){ | |
// we must process the email form | |
require_once('confirmation.php'); // require the file needed to process email form | |
} | |
} | |
function printError($msg){ | |
echo "<span class='error'>{$msg}</span>"; | |
} | |
?> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<title>Come Alive Chiropractic - Patients</title> | |
<style type="text/css" media="screen"> | |
@import "css/comealive_style.css"; | |
</style> | |
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'> | |
<link href='http://fonts.googleapis.com/css?family=Merriweather+Sans:400,800,700' rel='stylesheet' type='text/css'> | |
<script type="text/javascript"> | |
var RecaptchaOptions = { | |
theme : 'white' | |
}; | |
</script> | |
<!--[if gte IE 9]> | |
<style type="text/css"> | |
.gradient { | |
filter: none; | |
} | |
</style> | |
<![endif]--> | |
</head> | |
<body> | |
<header> | |
<div id="wrapper"> | |
<div class="container"> | |
<div id="logo"> | |
<a href="index.html"><img src="images/Come_Alive_Logo.png" width="250" height="125" alt="Come Alive Chiropractic Logo" /></a> | |
</div> | |
<nav class="global current"> | |
<ul class="list"> | |
<li><a href="index.html">Home</a></li> | |
<li><a href="about.html">About Us</a></li> | |
<li><a href="patients.html">Patients</a></li> | |
<li><a href="rx4.html">Rx4</a></li> | |
<li><a class="active" href="contact.php">Contact Us</a></li> | |
</ul><!--end list--> | |
</nav><!--end global--> | |
</div> | |
<div class="box"> | |
</div><!--end wrapper--> | |
</header><!--end header--> | |
<div id="content"> | |
<aside id="right"> | |
<div id="table"> | |
<thead> | |
<table border="0" cell padding="5" cellspacing="5" width="50%"> | |
<tr><th colspan="3" align="center" class="header">Office Hours</th></tr> | |
<div class"border"> | |
<tr><th class="th-bg">Day</th><th class="th-bg">Open</th><th class="th-bg">Close</th></tr><!--ends border--></div> | |
<tr><td class="center">Monday</td><td class="center">1:00 PM</td><td class="center">7:00 PM</td></tr></span> | |
<tr><td class="center">Tuesday</td><td class="center">1:00 PM</td><td class="center">7:00 PM</td></tr> | |
<tr><td class="center">Wednesday</td><td class="center">Closed</td><td class="center">Closed</td></tr> | |
<tr><td class="center">Thursday</td><td class="center">1:00 PM</td><td class="center">7:00 PM</td></tr> | |
<tr><td class="center">Friday</td><td class="center">12:00 PM</td><td class="center">6:00 PM</td></tr> | |
</thead> | |
</table> | |
<!--end table--></div> | |
<br> | |
<div id="contact-info"> | |
<p><strong class="st-head"><em>Come Alive Chiropractic</em></strong><br>16 South Main Street<br>Manheim, PA 17545</p> | |
<p><strong class="st-head"><em>Telephone</em></strong><br>717.665.1888</p> | |
</div> | |
</aside><!--end right--> | |
<div id="main"> | |
<h1 class="header">Contact Us</h1> | |
<article class="content-article"> | |
<h2>Reach out to us for any questions you have.</h2> | |
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet interdum lacus, ut malesuada enim ultrices vel. Curabitur vulputate condimentum consequat. Suspendisse eleifend dui at nisl adipiscing gravida. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Mauris ligula elit, euismod eu sollicitudin ac, gravida in eros. Nunc suscipit volutpat eleifend. Donec ut ligula lacus, sit amet aliquam eros. Donec viverra purus suscipit eros pretium vitae convallis mauris mollis. Cras vulputate metus at odio pretium adipiscing. Cras iaculis odio quis massa gravida ullamcorper. Morbi vitae nunc quis ante lobortis pharetra.</p> | |
</article> | |
<section id="contact-form"> | |
<?php if($action == 'Send' && ! $err): /* the form was submitted and there are no errors, thus the email send was successful */ ?> | |
<div style='color: green'>We have received your email, and you should receive a reply shortly! Thanks</div> | |
<?php else: /* the form was not submitted or there were errors, thus we need to display the form */ ?> | |
<div id="form"> | |
<form id="myForm" name="myForm" action="" method="post"> | |
<fieldset> | |
<legend>Send Us An Email!</legend> | |
<label for="name">Name:</label> | |
<span class="entry"><input type="text" id="name" name="name" value="<?= (isset($_POST['name'])) ? $_POST['name'] : null ?>" /></span> | |
<span class="err-msg"><?php if(isset($err['name'])){ printError($err['name']); } ?></span> | |
<br> | |
<br> | |
<label for="email">Email:</label> | |
<span class="entry"><input type="text" id="email" name="email" value="<?= (isset($_POST['email'])) ? $_POST['email'] : null ?>"/></span> | |
<span class="err-msg"><?php if(isset($err['email'])){ printError($err['email']); } ?></span> | |
<br> | |
<br> | |
<label for="comments">Comments:</label> | |
<span class="entry"><textarea id="comments" name="comments" rows="5" cols="30"><?= (isset($_POST['comments'])) ? $_POST['comments'] : null ?></textarea></span> | |
<span class="err-msg"><?php if(isset($err['comments'])){ printError($err['comments']); } ?></span> | |
<br> | |
<br> | |
<div id="captcha-container"> | |
<form method="post" action=""> | |
<?php | |
require_once('captcha/recaptchalib.php'); | |
$publickey = "6LclzuASAAAAAMgRFHMig_Zv81_xKMskaMxSDhlG"; // you got this from the signup page | |
echo recaptcha_get_html($publickey); | |
?> | |
<span class="err-msg"><?php if(isset($err['captcha'])){ printError($err['captcha']); } ?></span> | |
<br> | |
<input class="contact-submit" type="submit" name='__action' value='Send' /> | |
</form> | |
</div> | |
</fieldset> | |
</form> | |
</div><!--end form--> | |
<?php endif; ?> | |
</section> | |
</div><!--end main--> | |
</div><!--end content--> | |
</div><!--end box--> | |
<div id="footer-bg"> | |
<div class="box"> | |
<footer> | |
<div id="foot-container"> | |
<div class="courtesy-left"> | |
<nav class="courtesy"> | |
<ul class="clist"> | |
<li><a href="credits.html">Credits</a></li> | |
<li><a href="directions.html">Directions</a></li> | |
</ul><!--end clist--> | |
</nav><!--end courtesy--> | |
</div><!--end courtest-left--> | |
<div class="courtesy-center"> | |
<nav class="courtesy"> | |
<ul class="clist"> | |
<li><a href="faq.html">FAQ</a></li> | |
<li><a href="links.html">Links</a></li> | |
</ul><!--end clist--> | |
</nav><!--end courtesy--> | |
</div><!--end center-center--> | |
<div class="courtesy-right"> | |
<nav class="courtesy"> | |
<ul class="clist"> | |
<li><a href="privacy.html">Privacy Policy</a></li> | |
<li><a href="terms.html">Terms of Service</a></li> | |
</ul><!--end clist--> | |
</nav><!--end courtesy--> | |
</div><!--end courtesy-right--> | |
<a href="https://www.facebook.com/pages/Come-Alive-Chiropractic/141512509228230" target="_blank"><img src="images/facebook-64.png" width="64" height="64" alt="Facebook"></a> | |
<div id="copyright"> | |
<p>Copyright © 2013 Come Alive Chiropractic. All Rights Reserved.<br /> | |
Website Designed By <a href="http://www.innermindco.com" target="_blank">Inner Mind Co.</a></p> | |
</div><!--end copyright--> | |
</div><!--end foot-container--> | |
</footer><!--end footer--> | |
</div<!--end box--> | |
</div><!--end footer-bg--> | |
<!--</div><!--end wrapper--> | |
</body><!--end body--> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment