- Joined
- Jul 6, 2008
- Messages
- 173
- Reaction score
- 2
Well its easier than you think
Things Using
Example
http://darkcoders.co.nr/cap/
So lets get the php files together.
index.php
captcha.php
Download the attachment for everything together
Things Using
- 1 Font File
- 2 Images
- 2 Php Files
Example
http://darkcoders.co.nr/cap/
So lets get the php files together.
index.php
PHP:
<?php
//Creates the session to make sure the image matches text, and creates the form
session_start();
if(isset($_POST['submit']) && !empty($_POST['code'])){
$ses = $_SESSION['captcha'];
if($ses == $_POST['code']){
echo "Code is correct!";
}else{
echo "Code is incorrect!";
}
}else{
echo "<img src='captcha.php'><br>";
echo "<form action='' method='post'>"
."<input type='text' name='code'>"
."<br><input type=image src=others/submit.bmp name='submit' value=Submit alt=Submit><a href=index.php><img src='Others/refresh.bmp' border=0></a><br>"
."</form>";
}
?>
captcha.php
PHP:
<?php
//Creates The Image
session_start();
$im = imagecreatefromjpeg ("others/image.jpg");
$rand1 = rand(1,255);
$rand2 = rand(1,255);
$rand3 = rand(1,255);
$color = imagecolorallocate($im, $rand1, $rand2, $rand3);
$text = rand(1000, 9999);
$font = 'others/TACOBOX_.TTF';
$size = 20;
imagettftext($im, $size, 0, 5, 28, $color, $font, $text);
header('Content-type: image/jpg');
imagejpeg($im);
imagedestroy($im);
$_SESSION['captcha'] = $text;
?>
Download the attachment for everything together