Please note:
The above contact form is only a demonstration. If you wish to send a message to the CHouseLive team, please refer to the contact tab.
The php script on which this form is powered was written by Jemjabella
This is a php e-mail form and in order to use it, you will need to ensure that your server supports php and that the page, on which you save the form, is saved as a php file.
The script offers meta header and JavaScript injection protection as well as a spam word check and common spam bot blocking. The form itself not only validates but is also easy to implement and requires no additional file includes.
If you would like to learn more about how to create the actual php which drives this form, Jemjabella has written a tutorial which you can follow on tutorialtastic.
<div class="contact">
<h3>E-mail Contact Form</h3>
<h5>All fields marked with <strong>*</strong> are required.</h5>
<!--
Free PHP Mail Form v2 - Secure single-page PHP mail form for your website
Copyright (c) Jem Turner 2007, 2008
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
To read the GNU General Public License, see http://www.gnu.org/licenses/.
-->
<?php
$yourEmail = "you@yoursite.com"; // the email address you wish to receive these mails through
$yourWebsite = "WEBSITE NAME"; // the name of your website
$maxPoints = 4; // max points a person can hit before it refuses to submit - recommend 4
function isBot() {
$bots = array("Indy", "Blaiz", "Java", "libwww-perl", "Python", "OutfoxBot", "User-Agent", "PycURL", "AlphaServer", "T8Abot", "Syntryx", "WinHttp", "WebBandit", "nicebot");
$isBot = false;
foreach ($bots as $bot)
if (strpos($_SERVER['HTTP_USER_AGENT'], $bot) !== false)
$isBot = true;
if (empty($_SERVER['HTTP_USER_AGENT']) || $_SERVER['HTTP_USER_AGENT'] == " ")
$isBot = true;
return $isBot;
}
if ($_SERVER['REQUEST_METHOD'] == "POST") {
if (isBot())
exit("Bots not allowed.</p>");
function clean($data) {
$data = trim(stripslashes(strip_tags($data)));
return $data;
}
$points = (int)0;
$badwords = array("adult", "beastial", "bestial", "blowjob", "clit", "cum", "cunilingus", "cunillingus", "cunnilingus", "cunt", "ejaculate", "fag", "felatio", "fellatio", "fuck", "fuk", "fuks", "gangbang", "gangbanged", "gangbangs", "hotsex", "hardcode", "jism", "jiz", "orgasim", "orgasims", "orgasm", "orgasms", "phonesex", "phuk", "phuq", "porn", "pussies", "pussy", "spunk", "xxx", "viagra", "phentermine", "tramadol", "adipex", "advai", "alprazolam", "ambien", "ambian", "amoxicillin", "antivert", "blackjack", "backgammon", "texas", "holdem", "poker", "carisoprodol", "ciara", "ciprofloxacin", "debt", "dating", "porn", "link=", "voyeur");
$exploits = array("content-type", "bcc:", "cc:", "document.cookie", "onclick", "onload", "javascript");
foreach ($badwords as $word)
if (strpos($_POST['comments'], $word) !== false)
$points = 2;
foreach ($exploits as $exploit)
if (strpos($_POST['comments'], $exploit) !== false)
$points = 2;
if (strpos($_POST['comments'], "http://") === true || strpos($_POST['comments'], "www.") === true)
$points = 2;
if (isset($_POST['nojs']))
$points = 1;
if (preg_match("/(<.*>)/i", $_POST['comments']))
$points = 2;
if (strlen($_POST['name']) < 3)
$points = 1;
if (strlen($_POST['comments']) < 15 || strlen($_POST['comments'] > 1500))
$points = 2;
if (empty($_POST['name']) || empty($_POST['email']) || empty($_POST['location']) || empty($_POST['comments'])) {
$error_msg .= "Name, e-mail, location and message are required fields. \n";
} elseif (strlen($_POST['name']) > 15) {
$error_msg .= "The name field is limited at 15 characters. Your first name or nickname will do! \n";
} elseif (!ereg("^[A-Za-z' -]*$", $_POST['name'])) {
$error_msg .= "The name field must not contain special characters. \n";
} elseif (!ereg("^[_a-z0-9-] (\.[_a-z0-9-] )*@[a-z0-9-] (\.[a-z0-9-] )*(\.[a-z]{2,6})$",strtolower($_POST['email']))) {
$error_msg .= "That is not a valid e-mail address. \n";
} elseif (!empty($_POST['url']) && !preg_match('/^(http|https):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*) )(:(\d ))?\/?/i', $_POST['url']))
$error_msg .= "Invalid website url.";
if ($error_msg == NULL && $points <= $maxPoints) {
$subject = "Automatic Form Email";
$message = "You received this e-mail message through your website: \n\n";
foreach ($_POST as $key => $val) {
$message .= ucwords($key) . ": $val \r\n";
}
$message .= 'IP: '.$_SERVER['REMOTE_ADDR']."\r\n";
$message .= 'Browser: '.$_SERVER['HTTP_USER_AGENT']."\r\n";
$message .= 'Points: '.$points;
if (strstr($_SERVER['SERVER_SOFTWARE'], "Win")) {
$headers = "From: $yourEmail \r\n";
$headers .= "Reply-To: {$_POST['email']}";
} else {
$headers = "From: $yourWebsite <$yourEmail> \r\n";
$headers .= "Reply-To: {$_POST['email']}";
}
if (mail($yourEmail,$subject,$message,$headers)) {
echo '<h6>Your mail was successfully sent.</h6>';
} else {
echo '<h6>Your mail could not be sent this time.</h6>';
}
}
}
function get_data($var) {
if (isset($_POST[$var]))
echo htmlspecialchars($_POST[$var]);
}
if ($error_msg != NULL) {
echo '<h6><span>Error:</span><br />';
echo nl2br($error_msg) . "</h6>";
}
?>
<form action="name-of-page.php" method="post"><!-- ensure that action is equal to the name of the page you have places the form in. -->
<noscript><p><input type="hidden" name="nojs" id="nojs" /></p></noscript>
<h4>Personal Information</h4>
<div class="contact-field">
<p>
<label for="name">*Name:</label>
<input type="text" name="name" id="name" value="<?php get_data("name"); ?>" />
</p>
<p>
<label for="email">*E-mail:</label>
<input type="text" name="email" id="email" value="<?php get_data("email"); ?>" />
</p>
<p>
<label for="url">Website URL:</label>
<input type="text" name="url" id="url" value="<?php get_data("url"); ?>" />
</p>
<p>
<label for="location">*Location:</label>
<input type="text" name="location" id="location" value="<?php get_data("location"); ?>" />
</p>
</div>
<h4>*Message</h4>
<div class="contact-field">
<p>
<textarea name="comments" id="comments" rows="5" cols="38"><?php get_data("comments"); ?></textarea>
</p>
</div>
<p>
<input type="submit" name="submit" id="submit" value="Send" />
<input type="reset" name="reset" id="reset" value="reset" />
</p>
</form>
</div>
.contact{
width:370px;
margin:0 auto;
padding:15px;
font-family:tahoma;
font-size: 16px;
}
.contact h3{
padding:5px 0;
margin:0;
font-family: "Times New Roman", Times, serif;
color: #000060;
font-weight: normal;
font-size: 2em;
letter-spacing:.05em;
text-align:center
}
.contact h5{
padding:0 0 10px 0;
margin:0;
font-family: "Times New Roman", Times, serif;
color: #606060;
font-weight: normal;
font-size: .8em;
text-transform: uppercase;
letter-spacing:.05em;
text-align: center;
}
.contact form{
background: #F2F8FC;
padding: 20px 10px 10px 10px;
margin: 0;
}
.contact h4{
padding:5px 10px 0 10px;
margin:-10px 0 0 10px;
background: #C8E0F4;
color: #000;
font-weight: normal;
font-size: .9em;
float: left;
border-style: solid;
border-color: #F2F8FC;
border-width: 1px 1px 0 1px;
border-top-right-radius: 5px;
-moz-border-radius-topright: 5px;
-webkit-border-top-right-radius: 5px;
border-top-left-radius: 5px;
-moz-border-radius-topleft: 5px;
-webkit-border-top-left-radius: 5px;
}
.contact-field{
clear: both;
background: #C8E0F4;
border:none;
margin:0;
padding:10px 10px 20px 10px;
}
.contact label{
width: 100px;
display: block;
float: left;
color: #3C3C3C;
font-size: .85em;
}
.contact p{
padding:0;
margin:5px 0;
}
.contact h6{
background: #C8E0F4;
padding: 15px;
margin: 5px;
color: #3C3C3C;
font-weight: normal;
font-size: .9em;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
}
.contact span{
font-weight: bold;
color: #000;
font-size: .95em;
}
If you have encountered a problem with this demonstration, or would like an amendment made to the referencing and attributions of the scripts and code used on this page, please send the CHouseLive team an email: cara_remove_@chouselive_remove_.org