Showing posts with label captcha. Show all posts
Showing posts with label captcha. Show all posts

Tuesday, August 30, 2011

Drupal - Simple captcha


Hi,


This article is about using custom captcha in Drupal. This one is a custom created module in Drupal. This is developed under Drupal 6.20 environment. I am sure if you get a feel of it you can modify it for other versions as well.

You can get the code from here.

This is how it would look like:


Code & Explanation:

After you have downloaded the module. Install it in your project. Once done that, all you have to do is to put the following lines of code in your page form:

Monday, February 28, 2011

Simple home made captcha

Hi,

In this post I will give a very basic sample of creating your own captcha, with font, shape and size of your own choice. To achieve this we need the GD library to be enabled for you apache server. In this you need to create two php files and use a ttf file.

First we create the index.php file as follows:



<?php
session_start();
if(isset($_POST['captcha']))
{
if($_POST['captcha']==$_SESSION['captcha_code']){
echo "<font color='green'>Captcha code matched</font>";
}else{
echo "<font color='red'>Incorrect captcha code</font>";
}
echo "<br/>";
}

?>
<form action="" method="post">
<img id="captcha" src="captcha.php" /><br/>
<a href="javascript: void(0)" onclick="document.getElementById('captcha').src='captcha.php'">choose a different word</a>
<br/>
<input type="text" name="captcha" />
<input type="submit" value="Submit">
</form>


Now the second file you need is the captcha.php, which is as follows: