ÉÏ´úÂë:
ÑéÖ¤ÂëµÄͼƬ¡£
<img src="imgAuth.php" id="authnumimg" title="¿´²»Ç壿µã»÷»»ÕÅͼƬ£¡" onclick="this.src='imgAuth.php?a='+Math.random()"/>
Éú³ÉÑéÖ¤Âë²¢±£´æÔÚsessionÖеÄPHP,index.php
session_start();
$a=$_SESSION["VCODE"];
if($a==$_POST["authnum"]){
echo "ÑéÖ¤ÂëÏàͬ";
}else{
echo "ÑéÖ¤Â벻ͬ";
}
ͼƬÑéÖ¤Âë³ÌÐò:
class imgAuth{
session_start();
//Éú³ÉÑéÖ¤ÂëͼƬ
Header("Content-type: image/PNG");
$im = imagecreate(44,18);
$back = ImageColorAllocate($im, 245,245,245);
imagefill($im,0,0,$back); //±³¾°
srand((double)microtime()*1000000);
//Éú³É4λÊý×Ö
for($i=0;$i <4;$i++){
$font = ImageColorAllocate($im, rand(100,255),rand(0,100),rand(100,255));
$authnum=rand(1,9);
$vcodes.=$authnum;
imagestring($im, 5, 2+$i*10, 1, $authnum, $font);
}
for($i=0;$i <100;$i++) //¼ÓÈë¸ÉÈÅÏóËØ
{
$randcolor = ImageColorallocate($im,rand(0,255),rand(0,255),rand(0,255));
imagesetpixel($im, rand()%70 , rand()%30 , $randcolor);
µ±ÎÒÓÃPHPÏÂÔØ·þÎñÆ÷ÉϵÄwavÒôÀÖÎļþʱ£¬wavÎļþÄܹ»ÏÂÔØÏÂÀ´£¬²¢ÇÒ´óСÏàͬ£¬µ«ÊÇÈ´²»Äܲ¥·Å¡£µ«ÈôÊÇͨ¹ýÎļþ·þÎñÆ÷¿½±´µ½±¾µØ£¬ÊÇ¿ÉÒÔ²¥·Å¸ÃÎļþµÄ£¬²»ÖªµÀÈçºÎÔÒò¡£Í¨¹ýMD5sum¼ì²â£¬¸ÃÎļþÏÂÔØºóÒѸı䣬²»ÖªµÀÔ ......
ÎÒÔÚÍøÕ¾µÄÒýµ¼Ò³ÖÐÌí¼ÓÁË<embed src="ÒôÀÖµØÖ·" autostart="true" loop="true" hidden="true"></embed>
Õâ¾ä»°£¬È»ºóÌø×ªÒ³Ãæºó£¬±³¾°ÒôÀÖ¾ÍûÓÐÁË£¬ÔõôÈÃÕ ......