Arkadaşlar merhaba,
PHP formum için resim doğrulaması yapmak istiyorum.
Elimdeki kodlar sunucumda çalışmadı, sizce neden olabilir?
<?php
ob_start();
session_start();
function olustur () {
$sifre = substr(sha1(rand(0,999999999999)),-6);
$sifre= str_replace(array('0', 'O', 'o', '9', 'g', 'G'), rand(1, 8), $sifre);
if ($sifre) {
$_SESSION["captcha"] = $sifre;
$width = 130;
$height = 30;
$resim = ImageCreate($width,$height);
$x1 = rand(100,255);
$x2 = rand(100,255);
$x3 = rand(100,255);
$beyaz = ImageColorAllocate($resim,$x1, $x2, $x3);
$siyah = ImageColorAllocate($resim, 0, 0, 0);
$gray = ImageColorAllocate($resim, 210, 210, 210);
ImageFill($resim, 0, 0, $beyaz);
ImageRectangle($resim,0,0,$width-1,$height-1,$gray);
for ($i=0; $i<10; $i++) {
$x1 = rand(0,130);
$y1 = rand(0,30);
$x2 = rand(0,130);
$y2 = rand(0,30);
imageline($resim, $x1, $y1, $x2, $y2 ,$gray);
};
ImageString($resim, 5, 24, 7, $_SESSION["captcha"], $siyah);
header("Content,type: image/png");
ImagePng($resim);
ImageDestroy($resim);
}
}
olustur();
ob_end_flush();
?>Teşekkürler, iyi günler.