Current location: Hot Scripts Forums » Programming Languages » PHP » Getting Spam from my mailform again!

Getting Spam from my mailform again!

Reply
  #1 (permalink)  
Old 06-06-09, 01:26 PM
bally123 bally123 is offline
Newbie Coder
 
Join Date: Jul 2006
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Hazard Getting Spam from my mailform again!

I thought I had the perfect PHP mailform script but for some reason these damn bots are still bypassing the validation in my html by just linking straight to the php file I think

Can i insert some code so the mailform.php check the information is only being submitted from my site?

Here is my code

PHP Code:
<?php
////////////////////////////////////////////////////////////////
// PERFECT                                                    //
// -------                                                    //
// PHP E-mail Receive Form Electronic Content Text            //
// File: feedback.php                                         //
// Version: 1.8 (April 21, 2008)                              //
// Description: Processes a web form to read the user input   //
//    and then send the data to a predefined recipient.  You  //
//    are free to use and modify this script as you like.     //
// Instructions:  Go to "http://www.centerkey.com/php".       //
// License: Public Domain Software                            //
//                                                            //
// Center Key Software  *  www.centerkey.com  *  Dem Pilafian //
////////////////////////////////////////////////////////////////

// Configuration Settings
$SendFrom =    "$fname <$femail>";
$SendTo =      "info@domains.com";
$SubjectLine "$subject";
$ThanksURL =   "thanks.html";  //confirmation page

// Build Message Body from Web Form Input 
$MsgBody=<<<END
{
$_POST['fname']} has made an enquiry about{$_POST['subject']}\n\n{$_POST['fmess']}\n\nTheir contact details are:  
{$_POST['fname']}\n{$_POST['fadd1']}\n{$_POST['fadd2']}\n{$_POST['fcity']}\n{$_POST['fpost']}\n\n{$_POST['fnumber']}\n{$_POST['femail']}
END;
$MsgBody htmlspecialchars($MsgBodyENT_NOQUOTES);  //make safe 

// Send E-Mail and Direct Browser to Confirmation Page
      
if (count($_POST) > 0)
      
$Spam count($_POST) == || stristr($MsgBody"cc: ") ||
          
stristr($MsgBody"href=") || stristr($MsgBody"[url") || stristr($MsgBody"http://");
      if (!
$Spam)
          
mail($SendTo$SubjectLine$MsgBody"From: $SendFrom"); 
header("Location: $ThanksURL");
?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 06-06-09, 02:29 PM
Jcbones Jcbones is offline
Aspiring Coder
 
Join Date: Mar 2009
Location: North Carolina, USA
Posts: 414
Thanks: 4
Thanked 27 Times in 26 Posts
Look into honeypots they do work. Bots are blind to certain things.

one of them is 'styles'

Code:
<style type="text/css">
.check 
{
display:none;
}
</style>

<input class="check" type="text" name="email" value=""/>
PHP Code:
//script to validate honeypot
if($_POST['email'] != NULL)
{ echo 
'Your a spam bot, I will send no emails'}
else {
     
mail(myemails);

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 06-07-09, 07:29 AM
mdhall's Avatar
mdhall mdhall is offline
Aspiring Coder
 
Join Date: Oct 2003
Posts: 502
Thanks: 0
Thanked 0 Times in 0 Posts
CAPTCHA systems are pretty effective at stopping spam.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 06-08-09, 04:20 AM
bally123 bally123 is offline
Newbie Coder
 
Join Date: Jul 2006
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Is there away of preventing the script from being accessed from any other domain or ip other than the one its hosted on?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 06-08-09, 06:24 PM
Jcbones Jcbones is offline
Aspiring Coder
 
Join Date: Mar 2009
Location: North Carolina, USA
Posts: 414
Thanks: 4
Thanked 27 Times in 26 Posts
Yes,

.htaccess DENY/ALL
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 06-08-09, 09:28 PM
wirehopper's Avatar
wirehopper wirehopper is offline
Community Liaison
 
Join Date: Feb 2006
Posts: 2,327
Thanks: 17
Thanked 92 Times in 90 Posts
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 06-09-09, 02:44 PM
bally123 bally123 is offline
Newbie Coder
 
Join Date: Jul 2006
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Code:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://domain.com/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://domain.com$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.domain.com/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.domain.com$      [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp|php)$ - [F,NC]
Will this do or should I just use "deny from all"?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 06-09-09, 03:02 PM
wirehopper's Avatar
wirehopper wirehopper is offline
Community Liaison
 
Join Date: Feb 2006
Posts: 2,327
Thanks: 17
Thanked 92 Times in 90 Posts
Referrer isn't always reliable.

reCAPTCHA: Stop Spam, Read Books
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #9 (permalink)  
Old 06-19-09, 04:30 AM
bally123 bally123 is offline
Newbie Coder
 
Join Date: Jul 2006
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
The referer didnt work although my form has validation throughout including numbers only for the contact number I am still getting emails where they have bypassed the javascript validation on the form :doh:

is reCAPTCHA my only option? I am abit reluctant to use it because it puts potential customers off when trying to submit a quick enquiry.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #10 (permalink)  
Old 06-19-09, 06:40 AM
wirehopper's Avatar
wirehopper wirehopper is offline
Community Liaison
 
Join Date: Feb 2006
Posts: 2,327
Thanks: 17
Thanked 92 Times in 90 Posts
Other things you can try are to encrypt an email address or deliver it as an image on the page.

Hiding Your Email Address

Spam Proof eMail Address Generator

You can Google for more, there are many solutions.

These are nice options because clicking on the links allows the person to use their email client to send the message, instead of a web form. Saves you time on development and security. The only downside is that the person contacting you may not give you all the information - but - what you are almost guarenteed to get is their email address, which is the most important thing for responding.

Good luck.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Does it prevint SPAM !! Wanasa PHP 6 10-09-08 10:18 PM
SPAM via PHP contact form. seroxatmad PHP 6 11-28-06 01:24 AM


All times are GMT -5. The time now is 07:13 AM.
vBulletin® Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.