Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* CAPTCHA FILE */
- session_start();
- $_SESSION["rand"] = substr(str_shuffle("ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz"), 0, 6);
- $im = imagecreatetruecolor(62, 25);
- $bg = imagecolorallocate($im, 0, 140, 186);
- $fg = imagecolorallocate($im, 124, 119, 117);
- imagefill($im, 0, 0, $bg);
- imagestring($im, 5, 5, 5, $_SESSION["rand"], $fg);
- header("Cache-Control: no-cache, must-revalidate");
- header('Content-type: image/png');
- imagepng($im);
- imagedestroy($im);
- /* CAPTCHA FILE END */
- /* FORM FILE */
- session_start();
- // some code ...
- if(isset($_POST["captcha"]) && !empty($_POST["captcha"]) && !is_array($_POST["captcha"]))
- return $_POST["captcha"] == $_SESSION["rand"] ? true : false;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement