quocvuongdn

#php Make captcha image simple

Jun 2nd, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.39 KB | None | 0 0
  1. <?php
  2. ob_start();
  3. session_start();
  4.  header("Content-type: image/jpeg");
  5.  $im = imagecreate(120,25);
  6.  $white = imagecolorallocate($im, 16,17,32);
  7.  $black = imagecolorallocate($im, 255,255,255);
  8.  $randcode = rand(10000,99999);
  9.  $_SESSION['captcha']=$randcode;
  10.  
  11.  imagettftext($im, 16, 0, 11, 22, $black, "./fonts/04b_09__.ttf",  $_SESSION['captcha'] );
  12.  imagepng($im);
  13.  imagedestroy($im);
  14. ?>
Advertisement
Add Comment
Please, Sign In to add comment