Web Design Forum: TUTORIAL: Simple captcha - Web Design Forum

Jump to content

WDF
WDF Premium Memberships Reseller Hosting
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

TUTORIAL: Simple captcha Rate Topic: -----

#1 User is offline   webdesigner93 

  • Web Guru
  • PipPipPipPipPip
  • Group: Members
  • Posts: 1,976
  • Joined: 22-September 09
  • Reputation: 222
  • Gender:Male
  • Experience:Web Guru
  • Area of Expertise:Web Developer

Posted 22 November 2009 - 06:28 PM

Below is the code for a simple captcha i made i attached the captcha image to this post




 <?php
session_start();

$md5 = md5(microtime() * mktime());
$string = substr($md5,0,7);	
$cap = imagecreatefrompng("captcha.png");
$green = imagecolorallocate($cap,000,102,068); 
$blue = imagecolorallocate($cap,017,017,051); 
imageline($cap,39,5,65,33,$green);
 imageline($cap,81,7,5,31,$green);
 imageline($cap,0,7,82,25,$green);

imagestring($cap,5,20,10,$string,$blue);
$_SESSION['key'] = md5($string);


header("Content-type: image/png");

imagepng($cap);
?>


And when done the captcha should look like the image below

Attached File  pic.jpg (11.98K)
Number of downloads: 3

Attached File(s)


0

#2 User is offline   Acuity 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 449
  • Joined: 22-July 08
  • Reputation: 1
  • Gender:Male
  • Experience:Intermediate
  • Area of Expertise:Designer

Posted 23 November 2009 - 04:14 AM

nice
0

#3 User is offline   Peosan 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 14
  • Joined: 08-December 09
  • Reputation: 0
  • Gender:Male
  • Location:Sweden
  • Experience:Intermediate
  • Area of Expertise:Designer

Posted 10 December 2009 - 08:05 AM

Cool, thanks!
0

#4 User is offline   rallport 

  • Web Guru
  • PipPipPipPipPip
  • Group: Members
  • Posts: 3,813
  • Joined: 03-January 10
  • Reputation: 266
  • Gender:Male
  • Location:England, UK
  • Experience:Advanced
  • Area of Expertise:Web Developer

Posted 03 January 2010 - 02:47 PM

Nice and simple, but you should really put this in a class of its own.
0

#5 User is offline   Gareth Daine 

  • Web Guru
  • Group: Platinum Membership
  • Posts: 1,646
  • Joined: 01-November 08
  • Reputation: 26
  • Gender:Male
  • Location:Cumbria, UK
  • Experience:Web Guru
  • Area of Expertise:Designer/Coder

Posted 03 January 2010 - 02:55 PM

Decent, but I'd just use reCAPTCHA.

http://recaptcha.net/
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users