ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

½Ð°Ýµ{¦¡¦p¦ó¿ëÃѹϧÎÅçÃÒ½X

½Ð°Ýµ{¦¡¦p¦ó¿ëÃѹϧÎÅçÃÒ½X

½Ð°Ý¦U¦ì¤j¤j
¦³«Ü¦hºô­¶¡A»Ý­n¿é¤J¹Ï§Î¸ÌªºªºÅçÃÒ½X¡A¤~¯à¶i¤J¤U¤@¨B
«ç»òÅýµ{¦¡¦Û°Ê¿ëÃѳo¨Ç¹Ï§Î¸Ìªº¼Æ¦r»P¤å¦r?

¥»©«³Ì«á¥Ñ momokt1515 ©ó 2015-3-30 17:43 ½s¿è

±z¦n:
§A¥H¤U³o¬q¸Ü¡B¤£¤ÓÀ´±zªº·N«ä
½Ð°Ý¦U¦ì¤j¤j
¦³«Ü¦hºô­¶¡A»Ý­n¿é¤J¹Ï§Î¸ÌªºªºÅçÃÒ½X¡A¤~¯à¶i¤J¤U¤@¨B
«ç»òÅýµ{¦¡¦Û°Ê¿ëÃѳo¨Ç¹Ï§Î¸Ìªº¼Æ¦r»P¤å¦r?


§A¬O»Ý¨D ¹Ï«¬ÅçÃÒ½Xªº»yªk?
ÁÙ¬O­n¯}¸Ñ¥Lªº»yªk?


³o¬OÅçÃÒªºcode
/////////////////////////////////////////////////////////////////
<?php
$CaptchaString = "";        //ÅçÃÒ½X¤å¦r
$CaptchaLength = 5;                //ÅçÃÒ½Xªø«×

//²£¥Í¼Æ¦rÅçÃÒ½X
for($i=0; $i < $CaptchaLength; $i++)
        $CaptchaString = $CaptchaString.rand(0,9);

session_start();
$_SESSION['CAPTCHA'] = $CaptchaString;        //ÅçÃÒ½X¦s¤JSESSION¤º

Header("Content-type: image/PNG");        //«Å§i¿é¥X¬°PNG¼v¹³
$CaptchaWidth = 50;                                        //ÅçÃÒ½X¼v¹³¼e«×
$CaptchaHeight = 15;                                //ÅçÃÒ½X¼v¹³°ª«×

//«Ø¥ß¼v¹³
$Captcha = ImageCreate($CaptchaWidth, $CaptchaHeight);
//³]©w­I´ºÃC¦â¡A½d¨Ò¬O¬õ¦â
$BackgroundColor = ImageColorAllocate($Captcha, 255, 0, 0);
//³]©w¤å¦rÃC¦â¡A½d¨Ò¬O¶Â¦â
$FontColor = ImageColorAllocate($Captcha, 0, 0, 0);
//¼v¹³¶ñº¡­I´ºÃC¦â
ImageFill($Captcha, 0, 0, $BackgroundColor);
//¼v¹³µe¤WÅçÃÒ½X
ImageString($Captcha, 20, 0, 0, $_SESSION['CAPTCHA'] , $FontColor);
//ÀH¾÷µe¤W200­ÓÂI¡A°µ¬°Âø°T¥Î
for($i = 0; $i < 200; $i++) {
        Imagesetpixel($Captcha, rand() % $CaptchaWidth , rand() % $CaptchaHeight , $FontColor);
}
//¿é¥XÅçÃÒ½X¼v¹³
ImagePNG($Captcha);
ImageDestroy($Captcha);
?>


/////////////////////////////////////////////////////////////////

TOP

        ÀR«ä¦Û¦b : ÀR§¤±`®¦¤v¹L¡B¶¢½Í²ö½×¤H«D¡C
ªð¦^¦Cªí ¤W¤@¥DÃD