$message = stripslashes(htmlentites($_POST['message']));
<?php
$my_email = "Query'at'smg-computers.com";
$email = $_POST['Email'];
$subjectcmp = $_POST['Subject'];
$comments = $_POST['Comments'];
// This line prevents values being entered in a URL
if ($_SERVER['REQUEST_METHOD'] != "POST"){exit;}
$message = "";
// This line prevents a blank form being sent
while(list($key,$value) = each($_POST)){if(!(empty($value))){$set=1;}$message = $message . "$key: $value\n\n";} if($set!==1){header("location: $_SERVER[HTTP_REFERER]");exit;}
$message = $message;
$message = stripslashes($message);
$subject = "SMG Query - " . stripslashes($_POST['Subject']);
$headers = "From: " . (stripslashes(htmlentities($_POST['Email']))) . "\n" . "Return-Path: " . (stripslashes(htmlentities($_POST['Email']))) . "\n" . "Reply-To: " . (stripslashes(htmlentities($_POST['Email']))) . "\n";
if ($email && $subjectcmp && $message && $comments != NULL )
{
if (strstr($email, "'at'smg-computers.com"))
{
echo "Invalid Email Address" ?> <a href="javascript:history.go(-1)" onMouseOver="self.status=document.referrer;return true"> <br>Back </a> <?php ;
exit;
}
else
{
mail($my_email,$subject,$message,$headers);
}
}
else
{
echo "Make sure all fields are filled in." ?> <a href="javascript:history.go(-1)" onMouseOver= "self.status=document.referrer;return true"> <br>Back </a> <?php ;
exit;
}
?>
reset: as2677'at'smg-computers.com
Name: as2677'at'smg-computers.com
Confirm: as2677'at'smg-computers.com
Comments: as2677'at'smg-computers.com
Email: as2677'at'smg-computers.com
Subject: and
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: could not afford for the
bcc: [email protected]
8b13864ee0469736d57002df9366cb42
Al Vallario said:If the bots are too smart for the checkbox technique, you could always move on to the "What colour is an orange?" method, whereby a user is required to answer a simple question with a single-word answer before submitting the form. Alternatively, you could generate a random letter and ask the user to copy that letter into a form field.
You should include a short paragraph that explains the purpose of these measures, so users don't think it's a bit of a joke and ignore them
Could pick one of a number of questions at random. Also, I'm no expert on the matter, but I doubt bots are individually programmed for each website they hitrobmiller said:I don't see why, if a user can find your site and tell a bot to spam the form, they can't just tell it to add "answer=orange" along with the spam. It's not exactly rocket science.
If someone is targeting a specific website they will be.Al Vallario said:Could pick one of a number of questions at random. Also, I'm no expert on the matter, but I doubt bots are individually programmed for each website they hit
Al Vallario said:Could pick one of a number of questions at random. Also, I'm no expert on the matter, but I doubt bots are individually programmed for each website they hit
function check_email_address($email) {
// First, we check that there's one @ symbol, and that the lengths are right
if (!ereg("[^@]{1,64}@[^@]{1,255}", $email)) {
// Email invalid because wrong number of characters in one section, or wrong number of @ symbols.
return false;
}
// Split it into sections to make life easier
$email_array = explode("@", $email);
$local_array = explode(".", $email_array[0]);
for ($i = 0; $i < sizeof($local_array); $i++) {
if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) {
return false;
}
}
if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name
$domain_array = explode(".", $email_array[1]);
if (sizeof($domain_array) < 2) {
return false; // Not enough parts to domain
}
for ($i = 0; $i < sizeof($domain_array); $i++) {
if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) {
return false;
}
}
}
return true;
}
if ($email && $message && $comments != NULL )
{
if (strstr($email, "@smg-computers.com"))
{
echo "Invalid Email Address" ?> <a href="javascript:history.go(-1)" onMouseOver="self.status=document.referrer;return true"> <br>Back </a> <?php ;
exit;
}
else if (check_email_address($email))
{
mail($my_email,$subject,$message,$headers);
}
else
{
echo $email . ' is not a valid email address.'; ?> <a href="javascript:history.go(-1)" onMouseOver= "self.status=document.referrer;return true"> <br>Back </a> <?php ;
exit;
}
}
else
{
echo "Make sure all fields are filled in." ?> <a href="javascript:history.go(-1)" onMouseOver= "self.status=document.referrer;return true"> <br>Back </a> <?php ;
exit;
}