>  Q&A  >  본문

세션 사용 후 이미지 확인 코드에서 오류가 보고됨

세션을 열지 않고도 효과가 나타납니다. (인증코드 사진은 정상적으로 표시됩니다.)

------------- --- ----------화려한 구분선--------- -------


세션을 연 후의 효과입니다(사진 없음)


--------- - ------------------------------------------------- - ---

실례합니다 왜 이런가요

소스 코드는 정중히

--------------- -- -----

<?php

session_start();

$width = 300;

$height = 100 ;

$img = imagecreatetruecolor($width,$height);

$white = imagecolorallocate($img, 255, 255, 255);

$red = imagecolorallocate($img, 255, 0, 0);

imagefilled직사각형 ($img, 0, 0, $width, $height, setColor($img));

함수 setColor($img)

{

return imagecolorallocate($img,getColor(),getColor(), getColor( ));

}

function getColor()

{

return mt_rand(0,255);

}

function setNum($a,$b)

{

return mt_rand($a, $b );

}

function getCode()

{

return $string = Join('',array_rand(array_flip(array_merge(range(0,9),range('a','z')) ,범위('A','Z'))),4));

}

$str = getCode();

$_SESSION['verifycode'] = $str;

for($i= 0; $i<4;$i++)

{

$size = setNum(20,50);

$angle = setNum(-15,15);

$x = ($너비/4)* $i +mt_rand(1,9);

$y = mt_rand(($height/2),$height);

$color = setColor( $img );

$fontfile = './fonts/MSYH .ttf ';

$text = mb_substr(getCode(),$i,1,'utf-8')

imagettftext($img, $size, $angle, $x, $y, $color, $ 글꼴 파일, $text)

}

for($i=0;$i<1500;$i++)

{

imagesetpixel($img, mt_rand(0, $width), mt_rand(0, $height), setColor($img));

}

for($i=0;$i<3;$i++)

{

imageline($img, mt_rand(0, $width), mt_rand(0,$height), mt_rand(0, $ 너비), mt_rand(0,$height), setColor($img));

}

for($i=0;$i<3;$i++)

{

$cx = mt_rand(0, $width);

$cy = mt_rand(0, $height);

$width = mt_rand(0, $width/2);

$height = mt_rand(0, $height/2);

$start = mt_rand( 0, 360);

$end = mt_rand(0, 360);

$color = setColor($img);

imagearc($img, $cx, $cy, $width, $height, $start, $end, $color);

}

헤더('content-type:image/jpeg');

imagejpeg( $img );

imagedestroy( $img );

?>



富贵富贵2543일 전1352

모든 응답(2)나는 대답할 것이다

  • 直奔十维

    直奔十维2017-10-05 16:40:26

    임시파일은 자동으로 삭제되겠죠?
    게다가 데이터베이스 저장 세션도 고려해볼 수 있겠죠?

    회신하다
    0
  • 钟毅

    钟毅2017-10-04 14:03:31

    지금은 잘못된 일을 처리하고 있지 않은 것 같습니다. 간단한 사진 검증부터 시작해서 먼저 생각해 보시는 것을 추천드립니다. 이것은 매우 필요합니다. 다른 쓸모없는 코드를 제거하면 됩니다. 이미 사용자 비밀번호를 등록하고 확인했습니다. 이 사진 SESSION 문제를 단독으로 시도해 보겠습니다. 숨겨진 도메인을 등록해야 합니까?

    회신하다
    0
  • 취소회신하다