How to Make CAPTCHA

CAPTCHA comes from words : Completely Automated Public Turing-test to tell Computers And Humans apart. As the meaning of that sentence, it is being used over hundreds pages to avoid automated requests from any scripts, (especially on registration forms).
Captcha codes were restored in current page’s session and uses PHP scripts to produce image containing the [...]

CAPTCHA comes from words : Completely Automated Public Turing-test to tell Computers And Humans apart. As the meaning of that sentence, it is being used over hundreds pages to avoid automated requests from any scripts, (especially on registration forms).

Captcha codes were restored in current page’s session and uses PHP scripts to produce image containing the code. The visitor’s computer would not be able to read it. The one who able to read is human, in this case, is the visitor itself.

You need PHP to generate captcha code and store it in current session. Here is the example of the single one :

<?php
session_start();
$str = substr(md5(microtime()),0,8);
$_SESSION["captcha"] = $str;
$img = imagecreate(100,30);
$color = imagecolorallocate($img,59,89,153);
imagestring($img,10,10,10,$str,$color);
imagejpeg($img);
?>

Definition

  1. Session_start will ask server to start the session for your computer
  2. MD5 Microtime will generate randomized alpha numerical letter.
  3. Substr will cut your current randomized letter to 8 digits (i.e.)
  4. $_SESSION will store the letter in session with name “captcha” (i.e.)
  5. ImageCreate will surely create solid image with width 100px and height 30px.
  6. ImageColorAllocate colorize your generated image
  7. ImageString will write the letter to your generated image
  8. ImageJPEG will render the image and text within it as true image, the browser also treat this PHP file as JPEG image.

Save the current PHP document to (i.e.) captcha.php

Insert CAPTCHA to Page

The next task is pretty easy. You just have to load captcha.php using img tag. Here is the simple HTML Code :

<html>
<body>
<img src="http://yoursite.com/captcha.php" />
</body>
</html>

Posted on , ,

Bookmark and Share

2 Responses to “How to Make CAPTCHA”

  1. admin says:

    this is inspiring

  2. That will produce the image obviously,also it is dynamic.

Leave a Reply


AJAX Random Post

  • How to Get Qualified Backlinks

    Most of bloggers want to have a lot of backlinks to their sites. Backlinks always give positive impacts for sites on Google PageRank and of course on the real traffic popularity itself. There are several ways to get traffics, they are easy to achieve. You can see the description below: Use
  • Earn Money From Social Networks

    Social Networks had been created to help bloggers stay connected with others and build social community. It allows you to submit your own articles or stories. Each stories will be linked to your site and drive a lot of visitors to your blogs. Nowadays, there are a lot of Social Networks on the inte
  • Make WordPress Faster

    WordPress has become the best web platform which being used by million blogs all over the world. WordPress become famous because of its simplicity, clean, elegance, and user-friendly interface. It also being used over professional webmasters and beginners rookies. But not all of the wordpress fac
  • Related Post For Blogger

    For Blogger user and also developer, this plugin will just work fine fetching related post of your current page. The plugin itself fetch from google's record of the external links that possibly have related content as yours. You can freely put it on widget sidebar or below post or somewhere else yo
  • AdSense is Now Accept External Ad-Networks

    Hello all, when I login to my AdSense, i notified a message that Google Adsense is now accepting various Google-ad-networks. What does it mean? It means that as publisher, we can show other ad-networks beside of AdSense when there is no relevant ads on AdSense. With this opt, of course it will incre

References

Who am I ?

My name is Julian Widya Perdana. I study at University of Gadjah Mada, Yogyakarta. I am a young developer addicted in JavaScript, Plugins, Themes, AJAX, and PHP developement. If you feel satisfy with my work, please support me to keep it developed