ÓÃPHPÉú³ÉÑéÖ¤Âë¿ÉÒÔ½øÐеã»÷Ë¢ÐÂ
ÑéÖ¤ÂëµÄ´óÖÂÔÀíÊÇÕâÑùµÄ£¬Ê×ÏÈÉú³ÉÒ»¸öËæ»úÊý£¬È»ºóÔÚÊý¾ÝÊýÉÏÃæ¼ÓÉϸÉÈÅͼƬ£¬Í¬Ê±°Ñ¸ÃÊý¾ÝÉú³ÉͼƬ²¢Êä³ö¡£
Õâ¸öÊý¾Ý±£´æÔÚsessionÖС£È»ºó°ÑÓû§µÄÊäÈëÓë±£´æÔÚsessionÖеÄÊý¾Ý½øÐÐÆ¥Å䣬½øÐÐÑéÖ¤¡£
verifyCode.php´úÂëÈçÏ£º
<?php
Header("Content-type: image/PNG");
session_start();
//×¼±¸ºÃËæ»úÊý·¢ÉúÆ÷ÖÖ×Ó
srand((double)microtime()*1000000);
//×¼±¸Í¼Æ¬µÄÏà¹Ø²ÎÊý
$im = imagecreate(62,20);
$black = ImageColorAllocate($im, 0,0,0); //RGBºÚÉ«±êʶ·û
$white = ImageColorAllocate($im, 255,255,255); //RGB°×É«±êʶ·û
$gray = ImageColorAllocate($im, 200,200,200); //RGB»ÒÉ«±êʶ·û
//¿ªÊ¼×÷ͼ
imagefill($im,0,0,$gray);
while(($randval=rand()%100000)<10000);
{
$_SESSION["check_num"] = $randval;
//½«ËÄλÕûÊýÑéÖ¤Âë»æÈëͼƬ
imagestring($im, 5, 10, 3, $randval, $black);
}
//¼ÓÈë¸ÉÈÅÏóËØ
for($i=0;$i<200;$i++){
$randcolor = ImageColorallocate($im,rand(0,255),rand(0,255),rand(0,255));
imagesetpixel($im, rand()%70 , rand()%30 , $randcolor);
}
//Êä³öÑé֤ͼƬ
ImagePNG($im);
//Ïú»ÙͼÏñ±êʶ·û
ImageDestroy($im);
//header("content-type:image/png");
////¶¨Òåheader£¬ÉùÃ÷ͼƬÎļþ£¬×îºÃÊÇpng£¬ÎÞ°æÈ¨Ö®ÈÅ;
////Éú³ÉеÄËÄλÕûÊýÑéÖ¤Âë
//session_start();//¿ªÆôsession;
//$authnum_session = '';
//$str = 'abcdefghijkmnpqrstuvwxyz1234567890';
////¶¨ÒåÓÃÀ´ÏÔʾÔÚͼƬÉϵÄÊý×ÖºÍ×Öĸ;
//$l = strlen(str); //µÃµ½×Ö´®µÄ³¤¶È;
////Ñ»·Ëæ»ú³éÈ¡ËÄÎ»Ç°Ãæ¶¨ÒåµÄ×ÖĸºÍÊý×Ö;
//for($i=1;$i<=4;$i++)
//{
//$num=rand(0,l-1);
////ÿ´ÎËæ»ú³éȡһλÊý×Ö;´ÓµÚÒ»¸ö×Öµ½¸Ã×Ö´®×î´ó³¤¶È,
////¼õ1ÊÇÒòΪ½ØÈ¡×Ö·ûÊÇ´Ó0¿ªÊ¼ÆðËã;ÕâÑù34×Ö·ûÈÎÒâ¶¼ÓпÉÄÜÅÅÔÚÆäÖÐ;
//$authnum_session.= str($num);
////½«Í¨¹ýÊý×ÖµÃÀ´µÄ×Ö·ûÁ¬ÆðÀ´Ò»¹²ÊÇËÄλ;
//}
//session_register("authnum_session");
////ÓÃsessionÀ´×öÑéÖ¤Ò²²»´í;×¢²ásession,Ãû³ÆÎªauthnum_session,
////ÆäËüÒ³ÃæÖ»Òª°üº¬Á˸ÃͼƬ
////¼´¿ÉÒÔͨ¹ý_session["authnum_session"]À´µ÷ÓÃ
Ïà¹ØÎĵµ£º
À´Ô´ÓÚ£ºhttp://news.csdn.net/a/20100201/216819.html
CSDN±¨µÀ
SDTimes¸ß¼¶±à¼Alex HandyÔÚ²©¿Í
Öб¬ÁÏ£¬ÉÏÖÜFacebookÑûÇëÁËPHPºËÐÄÍŶӵ½¹«Ë¾ÌÖÂÛËûÃǵÄÐÂÏîÄ¿£º´ÓÍ·ÖØÐ´µÄPHPÔËÐп⡣ÖܶþËûÃǽ«Õýʽ·¢²¼Õâ¸öÏîÄ¿£¬²¢¿ªÔ´¡£
HandyÏàÐÅ£¬ÕâÊÇÁ½ÄêǰFacebookÕÐÀ¿µÄһλPHP¸ßÊÖËùΪ¡£
µ«Ò²ÓÐÍøÓÑÔÚ²©¿ÍÏÂÁôÑÔ˵£¬Fac ......
Óà PHP ¿ØÖÆä¯ÀÀÆ÷»º´æÊǷdz£ÈÝÒ׵ģ¬ÊÖ²áÉÏÒ²Ïà¹ØµÄ˵Ã÷£¬ÓÉÓںܶà³õѧÕßûÓаÑÊֲῴÍ꣬ËùÒÔ»¹ÊÇ»áÓÐºÜ¶à¹ØÓÚÕâ¸öÎÊÌâµÄÒÉÎÊ£¬¹ÊÔÚ´ËרÃÅ·¢Ò»ÆªÎÄÕ£¬Í¬Ê±¶ÔÏà¹ØµÄÓï·¨×öÁËÏêϸµÄ˵Ã÷£¬·½±ãÐÂÊÖ²éÔÄ¡£
¡¡¡¡Òª½â¾öÕâÒ»ÎÊÌ⣬¿ÉÒÔͨ¹ý PHP ÖÐµÄ header() º¯Êý£¬·¢ËÍÌØ¶¨µÄ»º´æ¿ØÖÆÔʼ HTTP ±êÍ·£¬¾ßÌå´úÂëÈçÏ£º
Exampl ......
Beginning Php And Mysql³ÌÐòÉè¼Æ
Beginning PHP and MySQL from Novice to Professional 3rd Edition
Head First PHP MySQL
The Essential Guide to DreamweaverCS3 with CSS Ajax and PHP
phpÊÖ²á
......
.Ò»¡¢×÷Óãº
PHPÖ»ÊÇÒÔHTTPÐÒ齫HTMLÎĵµµÄ±êÍ·Ë͵½ä¯ÀÀÆ÷£¬¸æËßä¯ÀÀÆ÷¾ßÌåÔõô´¦ÀíÕâ¸öÒ³Ãæ£¬ÖÁÓÚ´«Ë͵ÄÄÚÈÝÔòÐèÒªÊìϤһÏÂHTTPÐÒéÁË£¬ÓëPHPÎÞ¹ØÁË£¬¿É²ÎÕÕhttp://www.w3.org/Protocols/rfc2616/rfc2616¡£
......
1.ÓÃ;:
·þÎñÆ÷¿ÉÒÔÀûÓÃCookies°üº¬ÐÅÏ¢µÄÈÎÒâÐÔÀ´É¸Ñ¡²¢¾³£ÐÔά»¤ÕâЩÐÅÏ¢£¬ÒÔÅжÏÔÚHTTP´«ÊäÖеÄ״̬¡£Cookies×îµäÐ͵ÄÓ¦ÓÃÊÇÅж¨×¢²áÓû§ÊÇ·ñÒѾµÇÂ¼ÍøÕ¾£¬Óû§¿ÉÄÜ»áµÃµ½Ìáʾ£¬ÊÇ·ñÔÚÏÂÒ»´Î½øÈë´ËÍøÕ¾Ê±±£ÁôÓû§ÐÅÏ¢ÒÔ±ã¼ò»¯µÇ¼ÊÖÐø£¬ÕâЩ¶¼ÊÇCookiesµÄ¹¦Óá£ÁíÒ»¸öÖØÒ ......