Lost Password?

  #1 (permalink)  
Old 04-28-2008, 04:54 PM
Jaan's Avatar   
Jaan Jaan is offline
Moderator
 
Join Date: Dec 2006
Location: Estonia
Age: 17
Posts: 426
Last Blog:
Wadio Media Layout Com...
Rep Power: 9
Jaan will become famous soon enoughJaan will become famous soon enough
Send a message via MSN to Jaan
Default Creation of captcha

Hey there!

I was thinking.. there are many users who have asked from me.. how to create a captcha or that image where are those random numbers or letters.. so i thought i'll make one..

PHP Code:
<?php
header
('Content-type: image/jpg');
header('Content-type: image/jpg'); this means that it will be a jpg image (because our background will be jpg)

PHP Code:
$im imagecreatefromjpeg ("image.jpg"); 
$im = imagecreatefromjpeg ("image.jpg"); It will take image.jpg for our image's background
PHP Code:
$rand1 rand(1,255);
$rand2 rand(1,255);
$rand3 rand(1,255);
$color imagecolorallocate($im$rand1$rand2$rand3); 
$rand1 = rand(1,255);-
$rand2 = rand(1,255);- - Those variables will create a random number from 1 to 255 so we will have a random color for our text
$rand3 = rand(1,255);-
$color = imagecolorallocate($im, $rand1, $rand2, $rand3); - This will create a color for our text

PHP Code:
$text rand(10009999);
$font 'text-font.otf';
$size 30
$text = rand(1000, 9999); - This will create a random number between 1000 and 9999
$font = 'text-font.otf'; - This will be our font
$size = 30; - It will be font's size

PHP Code:
imagettftext($im$size07045$color$font$text);
imagejpeg($im);
imagedestroy($im); 
This will put your info together to form a image it's that simple..

Here's the full code:

PHP Code:
<?php
header
('Content-type: image/jpg');
$im imagecreatefromjpeg ("image.jpg");
$rand1 rand(1,255);
$rand2 rand(1,255);
$rand3 rand(1,255);
$color imagecolorallocate($im$rand1$rand2$rand3);
$text rand(10009999);
$font 'text-font.otf';
$size 30;
imagettftext($im$size07045$color$font$text);
imagejpeg($im);
imagedestroy($im);
?>
I attached this script's files also It includes text-font.oft, image.jpg and index.php files

I'll add the part 2 for it also tomorrow i guess
Attached Files To view attachments your post count must be 1 or greater. Your post count is 0 momentarily.
__________________


Cheap & Professional Web Design | Need help? Send a PM

Last edited by Jaan; 04-29-2008 at 05:26 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 04-28-2008, 05:31 PM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 19
Posts: 2,345
Last Blog:
PHP Function Overloadi...
Rep Power: 50
John is a glorious beacon of lightJohn is a glorious beacon of lightJohn is a glorious beacon of lightJohn is a glorious beacon of lightJohn is a glorious beacon of light
Send a message via AIM to John
Default Re: Creation of captcha

Nice tutorial. +rep.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum | My Blog
Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-29-2008, 05:26 AM
Jaan's Avatar   
Jaan Jaan is offline
Moderator
 
Join Date: Dec 2006
Location: Estonia
Age: 17
Posts: 426
Last Blog:
Wadio Media Layout Com...
Rep Power: 9
Jaan will become famous soon enoughJaan will become famous soon enough
Send a message via MSN to Jaan
Default Re: Creation of captcha

yay.. thank you
__________________


Cheap & Professional Web Design | Need help? Send a PM
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Fixed] Enable Captcha Image not working aravot easyContact 12 04-25-2008 05:09 AM
session creation failing in IE karan_736 Java Help 4 01-25-2008 10:50 PM
Implement Captcha? GMailGuy PHP Forum 1 12-26-2007 09:08 AM
[Added] Creation Date rolandd ionFiles 2 07-26-2007 12:43 PM
CAPTCHA Check Jonas PHP Forum 0 07-15-2006 07:22 PM


All times are GMT -5. The time now is 05:26 PM.

Contest Stats

John ........ 87.50000
dargueta ........ 75.00000
Xav ........ 50.00000
MeTh0Dz ........ 20.00000
gaylo565 ........ 18.00000
Johnnyboy ........ 3.00000

Contest Rules

Ads