Created
February 27, 2014 13:59
-
-
Save GiovanniK/9250569 to your computer and use it in GitHub Desktop.
Simple captcha
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
session_start(); | |
if (empty($_SESSION['captcha'])) | |
{ | |
$captcha = mt_rand(10000, 99999); | |
$_SESSION['captcha'] = $captcha; | |
} | |
else | |
{ | |
$captcha = $_SESSION['captcha']; | |
} | |
unset ($_SESSION['captcha']); | |
header ('Content-Type: image/png'); | |
$im = @imagecreatetruecolor(100, 40) or die('GD library not found :('); | |
$text_color = imagecolorallocate($im, 233, 14, 91); | |
imagestring($im, 10, 27, 10, $captcha, $text_color); | |
imagepng($im); | |
imagedestroy($im); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment