Webmaster Forum  

Go Back   Webmaster Forum > Marketing, SEO and Development > Programming
User Name
Password
Register FAQ Members List Calendar Transactions Store Search Today's Posts Mark Forums Read


[Guide] PHP Simple Image Verification.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-08-2008, 08:13
my_cool_name
Junior Member


Join Date: Jul 2008
Posts: 16
Trader Rating: (0)
Points: 0 (Donate)
5 F$/Referral Refer Friends
my_cool_name is on a distinguished road
Default [Guide] PHP Simple Image Verification.

index.htm
<form action="check.php" method="post">
<img src="cap.php"><input type="text" name="cap">
<input type="submit" value="Check">
</form>

check.php
<?php
if ($_SESSION['cap'] == $_POST['cap'])
echo "Correct.";
else
echo "Wrong.";
?>

cap.php
<?php
session_start();

$charNum = 6;
for ($i=1;$i<=$charNum;$i++) {
$ran = array(chr(rand(65,90)), rand(1,9));
$captchastr .= $ran[rand(0,1)];
}
$_SESSION['cap'] = $captchastr;
$captcha = imageCreate(150,40);

$backcolor = imageColorAllocate($captcha, 225, 235, 242);
$txtcolor = imageColorAllocate($captcha, 17, 80, 152);

for($i=1;$i<=$charNum;$i++) {
$font = "tahoma";
imagettftext($captcha,rand(14,20),0,($i*20),30,$tx tcolor,$font,substr($captchastr,($i-1),1));
}

$ecolor = imageColorAllocate($captcha, 217, 84, 100);
for($i=1; $i<=2;$i++)
imageellipse($captcha,rand(1,150),rand(1,40),rand( 40,100),rand(12,25),$ecolor);

for($i=1; $i<=5;$i++)
imageline($captcha, rand(1, 150), 0, rand(1, 150), 40, $txtcolor);

header('Content-type: image/jpeg');
imageJPEG($captcha);
imageDestroy($captcha);
?>
my_cool_name is offline
Reply With Quote
Reply


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Quick and simple image hosting. - Hostbigger GTFO Free web hosting offers and requests 2 07-06-2008 00:39
PHP Tutorial Sarunasas Website Design Forum 1 03-27-2008 00:00
80 cheap Script for sale teampower Content 0 06-29-2007 01:08
A Simple RSS Feed Phraser in PHP admans Website Design Forum 5 10-05-2005 11:59
How To : Improve Your PHP Programming admans Website Design Forum 0 07-17-2005 06:58

Resources : | Advertise at FHF | itextLink.com| Reseller Hosting| TextDot| iNamePros| Any Webmaster| Web Host| Dep3|


All times are GMT -4. The time now is 11:58.


Powered by: vBulletin
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.