iEntry 10th Anniversary Forum Rules Search
WebProWorld
Register FAQ Calendar Mark Forums Read
Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Share Thread: & Tags

Share Thread:

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-16-2007, 07:54 PM
Tim's Avatar
Tim Tim is offline
WebProWorld Veteran
 
Join Date: Jul 2004
Location: On the edge of the UK
Posts: 423
Tim RepRank 0
Default Script to disallow URLs from form fields?

My clients are constantly plagued by form responses filled with spammers' links.

I currently use .htaccess to block known spammers, a temporary solution but one that also bans whoever inherits the IPs, and image CAPTCHAs to block spambots but I realise these are not accessible. I also display the visitor's IP as a deterrent.

As spammers are mostly driven by including URLs in their polluting contributions, it would seem logical that a script that bars 'http' and 'www' from being submitted in any form fields would reduce this type of spam enormously. In most cases URLs are not required anyway.

Please can anyone link to/write such a validation script?

Many thanks,

Tim
__________________
Pleasure in the job puts perfection in the work. Aristotle (384-322 BC)
Reply With Quote
  #2 (permalink)  
Old 02-16-2007, 08:35 PM
sands's Avatar
WebProWorld Veteran
 
Join Date: Sep 2005
Location: Kerala, India
Posts: 395
sands RepRank 1
Default

If it is PHP you could have something like this:
Code:
if ((strstr(strtolower($fieldName), 'http://')) || (strstr(strtolower($fieldName), 'www'))) {
  print "No links are accepted in the ______ field!";
  return; }
__________________
My Nook | My Biz | My Photos
Reply With Quote
  #3 (permalink)  
Old 02-16-2007, 09:20 PM
Tim's Avatar
Tim Tim is offline
WebProWorld Veteran
 
Join Date: Jul 2004
Location: On the edge of the UK
Posts: 423
Tim RepRank 0
Default

Thanks Sands,

Unfortunately, all existing forms are handled by FormMail Perl with JavaScript validation so I don't think I can make your solution work, unless you know otherwise? I use PHP for the "REMOTE_ADDR" display but that doesn't write to the form.

I have been considering mass conversion to PHP but that would/will mean a lot of work for dozens of sites. Eek!

Thanks again for the nice script that I will use in future.
__________________
Pleasure in the job puts perfection in the work. Aristotle (384-322 BC)
Reply With Quote
  #4 (permalink)  
Old 02-17-2007, 09:52 AM
DaveSawers's Avatar
WebProWorld Veteran
 
Join Date: Dec 2006
Location: Calgary, Alberta, Canada
Posts: 492
DaveSawers RepRank 3DaveSawers RepRank 3
Default

Then do it in JavaScript.

On the form submit button, direct it to a JavaScript function instead of directly submitting the form. This function can then search the post entry for the offending text. if it isn't there, call the forms submit function.

You can use the same function for other form validation too, such as ensuring the poster puts in an e-mail address or other required field.

From your post, it sounds like you are already calling a JavaScript function before form submission so this should be a simple addition to it.
__________________
Dynamic Software Development
www.activeminds.ca
Reply With Quote
  #5 (permalink)  
Old 02-18-2007, 03:48 PM
Tim's Avatar
Tim Tim is offline
WebProWorld Veteran
 
Join Date: Jul 2004
Location: On the edge of the UK
Posts: 423
Tim RepRank 0
Default

Thanks Dave but I'm sure most form-spammers have JavaScript disabled.
__________________
Pleasure in the job puts perfection in the work. Aristotle (384-322 BC)
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 11:03 PM.



Search Engine Optimization by vBSEO 3.3.0