dome90uk
06-11-2008, 11:48 AM
hi,
I have been trying to stop spam being submitted via one of my forms. I have managed to filter out <a href=""> and [url] using the code below, checking 2 fields. I am using nms_formmail.pl to process the forms.
use CGI;
sub spam {
my $q = new CGI;
my $spamcheck = $q->param('lastname') || '';
my $comcheck = $q->param('address') || '';
my $corecheck = $q->param('core_products') || '';
my $urlcheck = $q->param('address') || '';
my $url2check = $q->param('core_products') || '';
if ($spamcheck ne '') {
print "Location: http://www.xxxxxxxxx.com/thankyou.asp\n\n";
exit;
}
elsif ($comcheck =~ /<(.|\n)*>/) {
print "Location: http://www.google.com/\n\n";
exit;
}
elsif ($corecheck =~ /<(.|\n)*>/) {
print "Location: http://www.google.com/\n\n";
exit;
}
elsif ($urlcheck =~ /[(.|\n)*]/) {
print "Location: http://www.google.com/\n\n";
exit;
}
elsif ($url2check =~ /[(.|\n)*]/) {
print "Location: http://www.google.com/\n\n";
exit;
}
}
spam();
I would also like to stop messages being sent if the postcode is over a certain length but i am seriously lacking perl scripting skills. Can anyone help please?
** EDIT ** A typical entry i get submitted for postcode is " postcode: sLGEEQUJUmPrioMeZR " i would like to filter out any entries that have 8 or more characters.
I have been trying to stop spam being submitted via one of my forms. I have managed to filter out <a href=""> and [url] using the code below, checking 2 fields. I am using nms_formmail.pl to process the forms.
use CGI;
sub spam {
my $q = new CGI;
my $spamcheck = $q->param('lastname') || '';
my $comcheck = $q->param('address') || '';
my $corecheck = $q->param('core_products') || '';
my $urlcheck = $q->param('address') || '';
my $url2check = $q->param('core_products') || '';
if ($spamcheck ne '') {
print "Location: http://www.xxxxxxxxx.com/thankyou.asp\n\n";
exit;
}
elsif ($comcheck =~ /<(.|\n)*>/) {
print "Location: http://www.google.com/\n\n";
exit;
}
elsif ($corecheck =~ /<(.|\n)*>/) {
print "Location: http://www.google.com/\n\n";
exit;
}
elsif ($urlcheck =~ /[(.|\n)*]/) {
print "Location: http://www.google.com/\n\n";
exit;
}
elsif ($url2check =~ /[(.|\n)*]/) {
print "Location: http://www.google.com/\n\n";
exit;
}
}
spam();
I would also like to stop messages being sent if the postcode is over a certain length but i am seriously lacking perl scripting skills. Can anyone help please?
** EDIT ** A typical entry i get submitted for postcode is " postcode: sLGEEQUJUmPrioMeZR " i would like to filter out any entries that have 8 or more characters.