NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming > CODE
Reload this Page PHP - Animated Captcha

CODE This forum is for posting code snippets and example scripts that aren't quite tutorials, but could be useful for others. You may post code snippets and/or completed scripts that you've written and want to share here.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 11-19-2008, 12:53 AM THREAD STARTER               #26 (permalink)
i love automation
 
xrvel's Avatar
Join Date: Nov 2007
Location: xrvel.com
Posts: 1,620
xrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant future
 




Originally Posted by ezimedia
HI

How does one add this to a script to protect it from spam...

Do you have instructions..

Tom
Hi,

For example in e-mail registration (such as Yahoo mail) usually we must enter image verification. If we do not enter the correct image text, the registration fails.
You can use this to protect your registration page / login page / comment page.
But you need to modify your old PHP script.
I have put an example in the download link.

For example you want to add captcha to your login page.

This is your old "login.php"
PHP Code:
<?php
$username 
$_POST['username'];
$password $_POST['password'];

if (
$username == '' || $password == '') {
   
header('Location: login-form.php?error=empty')
   exit();
} else {
   
// connect to database, etc
}

?>
You can modify it into this
PHP Code:
<?php
session_start
();// required

$username $_POST['username'];
????: NamePros.com http://www.namepros.com/code/434273-php-animated-captcha.html
$password $_POST['password'];

// Read the user's input
$captcha $_POST['captcha'];

// Load the captcha class
require_once(dirname(__FILE__).'/animatedcaptcha.class.php');

// Create captcha object
$img = new animated_captcha();
$img->session_name 'my_turing_test';
$img->magic_words('i am cool');

// Regenerate session id on invalid guess
$img->regenerate_session_id(true);

$valid $img->validate($user_guess);// validate user's input

if (!$valid) {
????: NamePros.com http://www.namepros.com/showthread.php?t=434273
   
header('Location: login-form.php?error=captcha')
   exit();
} else if (
$username == '' || $password == '') {
   
header('Location: login-form.php?error=empty')
   exit();
} else {
   
// connect to database, etc
}

?>
Kurniawan.
__________________
Last edited by xrvel; 11-19-2008 at 12:59 AM.
xrvel is offline  
Old 01-09-2009, 03:28 AM   #27 (permalink)
New Member
Join Date: Jan 2008
Posts: 2
nil_koushik is an unknown quantity at this point
 



thanks, it's look better...
nil_koushik is offline  
Old 06-04-2009, 12:37 AM   #28 (permalink)
Account Closed
Join Date: Dec 2008
Location: Boston, Ma
Posts: 650
CrackFeed.Com is a name known to allCrackFeed.Com is a name known to allCrackFeed.Com is a name known to allCrackFeed.Com is a name known to allCrackFeed.Com is a name known to allCrackFeed.Com is a name known to all
 



Marrow Donor Program Animal Rescue Autism Autism
Nice, but your images took about a minute to load for me, I am on 3.5 Mb/s connection.
CrackFeed.Com is offline  
Closed Thread


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


Liquid Web Smart Servers  
All times are GMT -7. The time now is 11:40 PM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger