Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Nice Simple Contact Form Re: Nice Simple Contact Form

#54336
ikthius
Member

after getting lots of spam, I added a captcha to the sites I am in charge of, and I added the simple math one, as I did not want to deal with a whole load of images that sometimes I can’t read.

this has greatly decreased the spam to virtually nill, but then I added other parts to my PHP script:

Code:
/*
******************* checking the script is filled in by humans *******************
*/
//if email contains nothing, refresh to google and exit the script
if($email == “”)
{
print ““;
exit;
}
//if hidden contains anything, refresh to google and exit the script
if ($hidden > “”)
{
print ““;
exit;
}
//if body contains nothing, refresh to google and exit the script
if($Body == “”)
{
print ““;
exit;
}
//if the HTML captcha answer is not the same as PHP captcha value, refresh to google and exit the script
if ($captchaHTML != $captchaPHP)
{
print ““;
exit;
}

/*
******************* checking the body for generated urls if so send to google *******************
*/
if(preg_match(“/http/i”, “$Body”))
{
print ““;
exit;
}
if(preg_match(“/a href/i”, “$Body”))
{
print ““;
exit;
}
if(preg_match(“/link=/i”, “$Body”))
{
print ““;
exit;
}

you could also use an .htaccess to deny access to a directory that the script is working from, and deny from all the bot servers/ip address, this should eliminate all spam