Jump to content

GD Image Issue


crimsonmoon

Recommended Posts

I run a site and every so often I'll check the user to make sure they are not a program by displaying an image using GD and have them click the button that matches the image.

Heres the image generation code.

[code]$image = imagecreate(140, 30);

$white = imagecolorallocate($image, 255, 255, 255);
$gray = imagecolorallocate($image, 210, 210, 210);
$black = imagecolorallocate($image, 0, 0, 0);

$string = "text code pulled from database here";


for ($i=0; $i<25; $i++) {
  $x1 = rand(0,140);
  $y1 = rand(0,30);
  $x2 = rand(0,140);
  $y2 = rand(0,30);
  imageline($image, $x1, $y1, $x2, $y2 , $gray); 
}


$size = rand(4, 5);
$x = rand(12 , 80);
$y = rand(7 , 12);
 


imagestring($image, $size, $x, $y, $string , $black);

imagepng($image);
imagedestroy($image);
[/code]

I call this page by doing this:

[code] <img src=\"page.php?user=$userid\"/>[/code]

This works for the most part.

It works great for me and does great for some of my users but some are reporting that sometimes the image doesn't match up to the choices. I can't get it to do it on me so I'm thinking it could be something to do with the cache settings on their browsers.

Am I using the image correct? Any ideas on what could be causing this?
Link to comment
https://forums.phpfreaks.com/topic/13299-gd-image-issue/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.