Guest User

Captcha.php

a guest
Mar 2nd, 2013
71
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. session_start();
  3. function randomText($length) {
  4.     $pattern = "1234567890abcdefghijklmnopqrstuvwxyz";
  5.     for($i=0;$i<$length;$i++) {
  6.       $key .= $pattern{rand(0,35)};
  7.     }
  8.     return $key;
  9. }
  10.  
  11. $_SESSION['tmptxt'] = randomText(8);
  12. $captcha = imagecreatefromgif("bgcaptcha.gif");
  13. $colText = imagecolorallocate($captcha, 0, 0, 0);
  14. imagestring($captcha, 5, 16, 7, $_SESSION['tmptxt'], $colText);
  15.  
  16. header("Content-type: image/gif");
  17. imagegif($captcha);
  18. ?>
RAW Paste Data