HiveMinds Forum Index HiveMinds
We've arrived. Please notify the admins of any problems.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Ok need some help again....

 
Post new topic   Reply to topic    HiveMinds Forum Index -> PHP
View previous topic :: View next topic  
Author Message
Eric T
Helper Bee


Joined: 10 Dec 2002
Posts: 284
Location: California

PostPosted: Wed Aug 19, 2009 1:59 pm    Post subject: Ok need some help again.... Reply with quote

I have a contact form that keeps getting spam, like this:

Quote:

A person is requesting that you contact them.
Name: Syncneind
Phone: 123456
Email: suiscelve@gmail.com
Company: google
Message: aycqlx Syncneind. http://gbuzlh.com kdcxwn


I have JavaScript validation on the form when it submits, so I think they
are just hitting the php file to send the email.
Here's what I have added to try and stop this, but it is not working...

Code:

if($_POST["name"] == "" && $_POST["fromform"] != "" && $_POST["fromform2"] != "sent")
{
echo '<script>';
echo 'top.location.href="index.html";';
echo '</script>';

}else{
$name = $_POST["name"];
$phone = $_POST["phone"];
$email_addy = $_POST["email_add"];
$company = $_POST["company"];
$message_1 = $_POST["message"];

if(!ereg("^[0-9]{3}-[0-9]{3}-[0-9]{4}$", $phone)) {
echo '<script>';
echo 'top.location.href="index.html";';
echo '</script>';
}


I don't think the phone check code is any good, but still haven't found other code to use...

Anyway, any help would be greatly appreciated....
_________________
http://www.tincanwebdesign.com
Back to top
View user's profile Send private message
^WingNut^
Site Admin


Joined: 09 Nov 2002
Posts: 1138
Location: Oklahoma, USA

PostPosted: Wed Aug 19, 2009 6:33 pm    Post subject: Reply with quote

All the script is doing is adding a JavaScript redirect to the results page. What you need to do is stop the form from sending the email. An idea that a brilliant HiveMinder (I believe it was Chlucy) had a while back to help prevent spam registrations on these forums was to add a hidden field to the form with no value. Since spambots typically fill out all fields in a form and humans will never fill in a hidden field (unless they're trying to hack the form), you just check the hidden field for having *any* value and reject the form submission if it does.

Regardless, including JavaScript in your attempts to thwart the spambots will usually be a futile effort.

Hope this helps!
_________________
^WingNut^

If at first you don't succeed, skydiving is not for you...
Back to top
View user's profile Send private message Visit poster's website
Eric T
Helper Bee


Joined: 10 Dec 2002
Posts: 284
Location: California

PostPosted: Wed Aug 19, 2009 6:47 pm    Post subject: Reply with quote

Yeah, I tried the blank field with "fromform" I have it check to make sure it is blank and I also added a "fromform2" which I set a value to try to see if they would change that...

It just seems that right now, no matter what I try, I keep getting the spam...


I didn't included the email code stuff... Just the code I am trying to use to get it to kick back to the index page...
_________________
http://www.tincanwebdesign.com
Back to top
View user's profile Send private message
^WingNut^
Site Admin


Joined: 09 Nov 2002
Posts: 1138
Location: Oklahoma, USA

PostPosted: Wed Aug 19, 2009 7:11 pm    Post subject: Reply with quote

Assuming the email code stuff follows what you put in without any conditions, it will execute regardless of any error checking you put in, because you are not stopping execution of the script. An example of valid error checking would be:
Code:

if ([data is invalid])
{
  die("Spambots be gone!");
} else
{
  sendEmail();
}


The above is obviously pseudo-code, but it illustrates the point. You need to make sure the email code only executes if the data is valid.
_________________
^WingNut^

If at first you don't succeed, skydiving is not for you...
Back to top
View user's profile Send private message Visit poster's website
Eric T
Helper Bee


Joined: 10 Dec 2002
Posts: 284
Location: California

PostPosted: Wed Aug 19, 2009 7:17 pm    Post subject: Reply with quote

I will say that 'I am sure that it is set NOT to execute if there is an error" but I know how many times I have said that before just to find out, dang did I really set it outside the brackets... anyway, I will check and let you know...
_________________
http://www.tincanwebdesign.com
Back to top
View user's profile Send private message
Eric T
Helper Bee


Joined: 10 Dec 2002
Posts: 284
Location: California

PostPosted: Thu Aug 20, 2009 8:11 pm    Post subject: Reply with quote

Eric T wrote:
I will say that 'I am sure that it is set NOT to execute if there is an error" but I know how many times I have said that before just to find out, dang did I really set it outside the brackets... anyway, I will check and let you know...



Embarassed

yep email code outside the validation brackets... thank you, you know how many times I looked at that stupid bit of code...

just when you think your getting the hang of something...

anyway... thank you very much
_________________
http://www.tincanwebdesign.com
Back to top
View user's profile Send private message
^WingNut^
Site Admin


Joined: 09 Nov 2002
Posts: 1138
Location: Oklahoma, USA

PostPosted: Fri Aug 21, 2009 10:21 pm    Post subject: Reply with quote

No problem! I can't tell you how many times I've spent hours banging my head against the desk only to have somebody else glance at my code and say, "Well, THERE'S your problem!" - having a fresh set of eyes look at the problem makes all the difference Surprised)

Its also interesting how many times the solution to a problem pops into your head when you clear your mind and think about something ELSE.
_________________
^WingNut^

If at first you don't succeed, skydiving is not for you...
Back to top
View user's profile Send private message Visit poster's website
chlucy
Dances with Penguins


Joined: 08 Nov 2002
Posts: 1564

PostPosted: Sun Aug 23, 2009 9:16 pm    Post subject: Reply with quote

Glad to see the hidden field is still working!

And Eric, half the time, the only reason I know to look for certain errors is because I've spent countless hours staring at the code and have made the same stupid mistakes before.
Back to top
View user's profile Send private message AIM Address
Eric T
Helper Bee


Joined: 10 Dec 2002
Posts: 284
Location: California

PostPosted: Sun Aug 23, 2009 11:34 pm    Post subject: Reply with quote

I often try the go and think about something else... thank you CoD2 Very Happy

I try an not get to down when I make those stupid mistakes...

It is nice to know that there is a place to go, so that someone can point them out to me though.... lol
_________________
http://www.tincanwebdesign.com
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    HiveMinds Forum Index -> PHP All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group