WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Creates a CAPTCHA image in PHP, which displays 5 numbers stored in a session.
Categories : PHP, GD image library, Form Processing, Security Click here to Update Your Picture
Rupali Gulande
Date : Oct 24th 2007
Grade : 3 of 5 (graded 2 times)
Viewed : 2484
File : 4705.zip
Images : No Images for this code example.
Search : More code by Rupali Gulande
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

CAPTCHAs are used to prevent automated software from performing actions which degrade the quality of a service of a given system, whether due to abuse or resource expenditure. Creates a CAPTCHA image in PHP, which displays 5 numbers. The code is stored in a session variable ... then, the user must enter the code correctly. Can be used on registration forms, login forms, etc.

<?php
    session_start
();
   
header('Content-type: image/png');
   
$im = imagecreate(180, 70);
   
$lcolor1 = imagecolorallocate($im, 0,0,0);
   
$lcolor2 = imagecolorallocate($im, rand(0,70),rand(0, 70),rand(0, 70));
   
$bgcolor2 = imagecolorallocate($im, rand(200, 255),rand(200, 255),rand(200, 255));
   
$_SESSION['code'] = str_replace('7', '1', rand(10000, 99999));
   
$id = $_SESSION['code'];
   
imagefill($im, 0, 0, $bgcolor2);
   
$end1 = rand(0, 100);
   
imagefilledrectangle($im, 0, 0, $end1, 70, ImageColorAllocate($im, rand(235, 255),rand(235, 255),rand(235, 255)));
   
$end2 = $end1+rand(0, 100);
   
imagefilledrectangle($im, $end1, 0, $end2, 70, ImageColorAllocate($im, rand(235, 255),rand(235, 255),rand(235, 255)));
   
$end3 = $end2+rand(0, 100);
   
imagefilledrectangle($im, $end2, 0, $end3, 70, ImageColorAllocate($im, rand(235, 255),rand(235, 255),rand(235, 255)));
   
imagefilledrectangle($im, $end3, 0, 180, 70, ImageColorAllocate($im, rand(235, 255),rand(235, 255),rand(235, 255)));
   
$y1 = rand(25, 50);
   
ImageTTFText ($im, rand(17, 20), rand(-30, 30), rand(10, 20), $y1, $lcolor1, 'fonts/verdana.ttf', substr($id, 0, 1));
   
$y2 = rand(25, 50);
   
ImageTTFText ($im, rand(17, 20), rand(0, 30), rand(45, 55), $y2, $lcolor2, 'fonts/trebuc.ttf', substr($id, 1, 1));
   
$y3 = rand(25, 50);
   
ImageTTFText ($im, rand(17, 25), rand(-20, 0), rand(80, 90), $y3, $lcolor1, 'fonts/trebuc.ttf', substr($id, 2, 1));
   
$y4 = rand(25, 50);
   
ImageTTFText ($im, rand(16, 25), rand(0, 30), rand(115, 125), $y4, $lcolor1, 'fonts/verdana.ttf', substr($id, 3, 1));
   
$y5 = rand(25, 50);
   
ImageTTFText ($im, rand(18, 20), rand(-25, 0), rand(150, 160), $y5, $lcolor2, 'fonts/trebuc.ttf', substr($id, 4, 1));
   
$x = rand(0, 50);
   
$y = rand(0, 50);
     
imagepng($im);
?>



A damaged image generator (class) for validating text. CAPTCHA - Completely Automated Public Turing test to tell Computers and Humans Apart
Categories : PHP, PHP Classes, Security, GD image library, Security
addslashes automatically to $_POST variables
Categories : PHP, Form Processing, Security
CAPTCHA[Image verification]
Categories : PHP, Security, GD image library, Graphics, Sessions
Dynamic Image Authentication System in Signup Pages (CAPTCHA)
Categories : PHP, Security, GD image library
send_mail function to defeat Header Injection Hacking/Spamming
Categories : PHP, Email, Form Processing, Security
A captcha image allows you to prevent spam posting when users reload the page and stop bots from submitting forms automatically. This version allows you to use your own fonts (.ttf) to show the text.
Categories : PHP, Security, Graphics, GD image library
Generate image with random number (CAPTCHA)
Categories : PHP, GD image library, Graphics, Security
Securing Web Forms with Simple PHP-CAPTCHA (Completely Automated Public Turing test to tell Computers and Humans Apart)
Categories : PHP, Security, GD image library, Sessions
A PHP function to encrypt and decrypt a number or string or a combination of the two.
Categories : PHP, Encryption, Security
Create Thumbnails - resize an image - jpeg, jpg, gif, png to the specifed width and height in proportion without loosing out on pixcel quality.
Categories : PHP, GD image library, Graphics
Dollar Serial Number Validator
Categories : PHP, Security, Algorithms
A very simple PHP single password cookie based login without usernames.
Categories : PHP, Cookies, Security, Beginner Guides
MD5 secured login
Categories : PHP, Java Script, Authentication, Security
Secure URL $_GET
Categories : PHP, Data Validation, Security
Encoding data using PGP via PHP's proc_* functions
Categories : Cryptography, Security, Email, PHP, PGP