Lost Password?


  #1 (permalink)  
Old 04-28-2008, 05:54 PM
Jaan's Avatar   
Jaan Jaan is offline
Mod
 
Join Date: Dec 2006
Location: Estonia
Age: 17
Posts: 937
Last Blog:
AdStar Ad Control Pa...
Rep Power: 17
Jaan is just really niceJaan is just really niceJaan is just really niceJaan is just really nice
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 in this forum your post count must be 1 or greater. You currently have 0 posts.
__________________


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

Last edited by Jaan; 04-29-2008 at 06: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, 06:31 PM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 3,478
Last Blog:
Joomla! And Incompeten...
Rep Power: 20
John has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond repute
Send a message via AIM to John Send a message via MSN 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, 06:26 AM
Jaan's Avatar   
Jaan Jaan is offline
Mod
 
Join Date: Dec 2006
Location: Estonia
Age: 17
Posts: 937
Last Blog:
AdStar Ad Control Pa...
Rep Power: 17
Jaan is just really niceJaan is just really niceJaan is just really niceJaan is just really nice
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
  #4 (permalink)  
Old 08-18-2008, 08:55 PM
dreamcoder dreamcoder is offline
Newbie
 
Join Date: Aug 2008
Posts: 1
Rep Power: 0
dreamcoder is on a distinguished road
Default Re: Creation of captcha

Love it, thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 08-19-2008, 02:14 PM
Xav's Avatar   
Xav Xav is offline
Code Warrior
 
Join Date: Mar 2008
Location: On God's Planet
Posts: 9,897
Last Blog:
Web slideshow in JavaS...
Rep Power: 78
Xav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud of
Send a message via MSN to Xav
Default Re: Creation of captcha

This might not be safe - ya know, these types of CAPTCHAs have been broken.
__________________


Mr. Xav | Website | Forums | Blog
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #6 (permalink)  
Old 08-19-2008, 03:09 PM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 3,478
Last Blog:
Joomla! And Incompeten...
Rep Power: 20
John has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond repute
Send a message via AIM to John Send a message via MSN to John
Default Re: Creation of captcha

Quote:
Originally Posted by Xav View Post
This might not be safe - ya know, these types of CAPTCHAs have been broken.
Yes, but about 75% of the time they work. Which is a lot better than not having one.
__________________
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
  #7 (permalink)  
Old 08-19-2008, 03:23 PM
Xav's Avatar   
Xav Xav is offline
Code Warrior
 
Join Date: Mar 2008
Location: On God's Planet
Posts: 9,897
Last Blog:
Web slideshow in JavaS...
Rep Power: 78
Xav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud of
Send a message via MSN to Xav
Default Re: Creation of captcha

True, although it's still better to have a safe one.
__________________


Mr. Xav | Website | Forums | Blog
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 08-21-2008, 03:12 PM
vikas1234 vikas1234 is offline
Newbie
 
Join Date: Aug 2008
Posts: 10
Rep Power: 0
vikas1234 is on a distinguished road
Default Re: Creation of captcha

thnks a lot man its really useful
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 11-22-2008, 07:47 PM
Blizz Blizz is offline
Newbie
 
Join Date: Nov 2008
Posts: 1
Rep Power: 0
Blizz is on a distinguished road
Default Re: Creation of captcha

thank you
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 11-24-2008, 10:05 AM
Jaan's Avatar   
Jaan Jaan is offline
Mod
 
Join Date: Dec 2006
Location: Estonia
Age: 17
Posts: 937
Last Blog:
AdStar Ad Control Pa...
Rep Power: 17
Jaan is just really niceJaan is just really niceJaan is just really niceJaan is just really nice
Send a message via MSN to Jaan
Default Re: Creation of captcha

You're welcome
__________________


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

Sponsored Links
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
Forum Jump

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


All times are GMT -5. The time now is 08:50 AM.