Anti Spam Script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ninethousandfeet
Forum Contributor
Posts: 130
Joined: Tue Mar 10, 2009 4:56 pm

Anti Spam Script

Post by ninethousandfeet »

hello,
i am trying to add a simple anti-spam script using the sum of 1+2, but it will not work properly... right now i have a column in my userTable as 'test' varchar(5) not NULL. i've also tried to make this column ENUM with set values already at '3','three'...
is it a problem with my error code? database? or am i forgetting to define the variable or something??... or none of the above :)

thank you!

Code: Select all

 
// test question
  if (empty($_POST['test']) || $_POST['test'] != 3 || strtolower($_POST['test']) != 'three') {
      $error[] = 'Check your math.';
  }
 
...then this is the part where it shows up in my form

Code: Select all

 
  <td nowrap="nowrap" align="right">Sum of 1 and 2?</td>
        <td><input name="test" type="text" id="test" value="" size="32" /></td>
User avatar
kaisellgren
DevNet Resident
Posts: 1675
Joined: Sat Jan 07, 2006 5:52 am
Location: Lahti, Finland.

Re: Anti Spam Script

Post by kaisellgren »

It is very easy to write a bot that takes the spam challenge and solves it. Why not use a CAPTCHA? Would be much better.
ninethousandfeet
Forum Contributor
Posts: 130
Joined: Tue Mar 10, 2009 4:56 pm

Re: Anti Spam Script

Post by ninethousandfeet »

i was going to use this for starters, but i'm all ears. do you have any recommendations so i can learn how to write that script? i'm fairly new to development so i'm kind of all over the place.

thank you
User avatar
kaisellgren
DevNet Resident
Posts: 1675
Joined: Sat Jan 07, 2006 5:52 am
Location: Lahti, Finland.

Re: Anti Spam Script

Post by kaisellgren »

ninethousandfeet wrote:i was going to use this for starters, but i'm all ears. do you have any recommendations so i can learn how to write that script? i'm fairly new to development so i'm kind of all over the place.

thank you
Writing a CAPTCHA is hard if you want it to be good. As you are a beginner, I would recommend to use something simple like http://recaptcha.net/
ninethousandfeet
Forum Contributor
Posts: 130
Joined: Tue Mar 10, 2009 4:56 pm

Re: Anti Spam Script

Post by ninethousandfeet »

okay, i'll definitely take a look... i would prefer to not have the CAPTCHA on my home screen since my login and new user registration are both on that page. i would much rather have the user fill out the registration form, go to a new page with the CAPTCHA verification, and then to a 'thank you' page. ... then on kind of a different subject, i would like the user to have to click a link in their email to verify the account so i can validate the emails entered into my database are legitimate.

i guess my main question is how do i pass the information from a new registration form to another page without setting it in the database. i don't want a user to press 'register' and then be able to login if they have yet to do the CAPTCHA and email verification.
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Re: Anti Spam Script

Post by jayshields »

ninethousandfeet wrote:i guess my main question is how do i pass the information from a new registration form to another page without setting it in the database.
sessions
ninethousandfeet
Forum Contributor
Posts: 130
Joined: Tue Mar 10, 2009 4:56 pm

Re: Anti Spam Script

Post by ninethousandfeet »

do i insert the registration info into a temporary table and then pass that with a session variable to the page with CAPTCHA? i just don't see how i can avoid a user filling out the registration form, closing the following CAPTCHA page, returning to the login page, and login... having never completed the CAPTCHA verification and email verification.

my current understanding of sessions are they allow access to a page based on whether that user has logged in.

any advice is helpful, thank you!
Post Reply