Security Image (captcha)

I have created a class to easy the pain of generating captcha functionality on your registration (and what ever else) pages. Its a simple class and easy to use.

You can download here: Wattz.net Download Page

Requirements:
– Php5+ (with GD enabled)
– GD

Usage:

$width = 100;
$height = 80;
$Chars = 8; //number of characters.
$lines = 100; //number of background lines.
$SecurityImage = new SecImg($width, $height, $Chars, $lines);
$SecurityImage->Create();
Here is an example setup for complete usage:

::::::::: USER REGISTRATION PAGE:

<form>
….
<img src=”securityImage.php”>
<input type=”text” name=”securityCode”>

<input type=”submit” value=”submit”>

</form>

:::::::::: Now for SecurityImage.php

<?php
session_start();
include(“securityImageClass.php”);

$img = new SecImg(100,40);
$img->Create();

$_SESSION[‘securityCode’] = $img->code;

?>

:::::::::: Then you can validate in your registration page processing script like

<?php

session_start();

if($_POST[‘securityCode’] != $_SESSION[‘securityCode’])
{
die(“Security Code does not match”);
}

?>

Like I said, that is an example, there are many ways to do it. Well I hope you find this useful and I look forward to contributing more in the future.

_Wess

Advertisements

3 responses to “Security Image (captcha)

  1. cant see sucurity code

  2. Not able to create an image. Does it requires something more?

  3. Its actually a nice and helpful piece of information. Im glad that you shared this useful information with us. Please keep us up to date like this. Thanks for sharing. ebfeeegeadck

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s